ScriptManager and Form in pages created at runtime in class librar
am 11.04.2008 15:23:01 von pedrosferreira
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
RE: ScriptManager and Form in pages created at runtime in class librar
am 11.04.2008 16:01:01 von pedrosferreira
Ok, obviously, this was a silly mistake on my side. I forgot that I was
creating the whole page, and didn't created the
and the
elements.
It seems to be working as expected now. Sorry for the mistake.
Pedro
"Pedro Ferreira" wrote:
> 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