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.Pr ocessRequest implementation
Page page = new TestPage();
page.AppRelativ eVirtualPath =
context.Request .AppRelativeCur rentExecutionFi lePath;
page.ProcessReq uest(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 MicrosoftAjaxWe bForms.debug.js , line 878
(this._onsubmit = this._form.onsu bmit;) 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 CreateChildCont rols()
{
base.CreateChil dControls();
HtmlForm form = new HtmlForm();
form.ID = "form";
Controls.Add(fo rm);
ScriptManager sm = new ScriptManager() ;
form.Controls.A dd(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.Pr ocessRequest implementation
Page page = new TestPage();
page.AppRelativ eVirtualPath =
context.Request .AppRelativeCur rentExecutionFi lePath;
page.ProcessReq uest(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 MicrosoftAjaxWe bForms.debug.js , line 878
(this._onsubmit = this._form.onsu bmit;) 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 CreateChildCont rols()
{
base.CreateChil dControls();
HtmlForm form = new HtmlForm();
form.ID = "form";
Controls.Add(fo rm);
ScriptManager sm = new ScriptManager() ;
form.Controls.A dd(sm);
}
}
Any idea on how to do this?
Thanks,
Pedro Ferreira
Comment