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
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