ScriptManager and Form in pages created at runtime in class librar

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?UGVkcm8gRmVycmVpcmE=?=

    ScriptManager and Form in pages created at runtime in class librar

    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
  • =?Utf-8?B?UGVkcm8gRmVycmVpcmE=?=

    #2
    RE: ScriptManager and Form in pages created at runtime in class librar

    Ok, obviously, this was a silly mistake on my side. I forgot that I was
    creating the whole page, and didn't created the <headand the <body>
    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.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

    Working...