ScriptManager and Form in pages created at runtime in class librar

P

Pedro Ferreira

Hello,

We have a situation where we need to create web pages in a class library and
serve them dynamically (there is no .aspx page on the web site file system).
We created a custom handler that looks like this:

/////// IHttpHandler.ProcessRequest implementation
Page page = new TestPage();
page.AppRelativeVirtualPath =
context.Request.AppRelativeCurrentExecutionFilePath;
page.ProcessRequest(context);
//////

This is working fine. The problem is that the page we are creating
(TestPage) needs a script manager and other controls that require a form,
although I can't find a way to set the Page's form (the one returned by the
Form property) in code.

I partially solved this by adding an HtmlForm to the page, and add the other
controls to it. However, when I add a script manager to the created form, I
get a javascript error on MicrosoftAjaxWebForms.debug.js, line 878
(this._onsubmit = this._form.onsubmit;) saying that this._form has no
properties, which indicates that the form is not properly set (the line above
says: // TODO: Check that we found the form).

The TestPage class looks like this:

public class TestPage : Page
{
protected override void CreateChildControls()
{
base.CreateChildControls();

HtmlForm form = new HtmlForm();
form.ID = "form";
Controls.Add(form);

ScriptManager sm = new ScriptManager();
form.Controls.Add(sm);
}
}

Any idea on how to do this?

Thanks,

Pedro Ferreira
 
P

Pedro Ferreira

Ok, obviously, this was a silly mistake on my side. I forgot that I was
creating the whole page, and didn't created the <head> and the <body>
elements.

It seems to be working as expected now. Sorry for the mistake.

Pedro
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,709
Latest member
AustinMudi

Latest Threads

Top