Off-Page Rendering of Server Controls with events

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bob Jones

    #1

    Off-Page Rendering of Server Controls with events

    Hey everyone. I have another problem. I have an aspx web page that
    contains an event. When the event is fired it creates an instance of a
    server control that contains an event of its own. I would like to be
    able to render the contents of the server control (HTML w/ event
    JavaScript code) and store it for later use.

    My problem lies when I call the MyControl.Rende rControl method. It
    returns valid HTML but does not contain the event code since the
    control has not been added to any page object.

    Here is what I have tried:

    HtmlForm hForm = new System.Web.UI.H tmlControls.Htm lForm();
    hForm.Attribute s.Add("runat", "server");
    hForm.Controls. Add(spWC);

    Page p = new Page();
    p.Controls.Add( hForm);
    p.RenderControl (hWriter); // <-- error here stating that no Response
    object available.

    I do understand that I am getting a "Response not available" error
    because there is no context associated with the newly created page
    object. Any ideas as to how I can achieve the results I am looking
    for?

    -David

  • Bob Jones

    #2
    Re: Off-Page Rendering of Server Controls with events

    On Feb 21, 9:15 am, "Bob Jones" <goodold...@gma il.comwrote:
    Hey everyone. I have another problem. I have an aspx web page that
    contains an event. When the event is fired it creates an instance of a
    server control that contains an event of its own. I would like to be
    able to render the contents of the server control (HTML w/ event
    JavaScript code) and store it for later use.
    >
    My problem lies when I call the MyControl.Rende rControl method. It
    returns valid HTML but does not contain the event code since the
    control has not been added to any page object.
    >
    Here is what I have tried:
    >
    HtmlForm hForm = new System.Web.UI.H tmlControls.Htm lForm();
    hForm.Attribute s.Add("runat", "server");
    hForm.Controls. Add(spWC);
    >
    Page p = new Page();
    p.Controls.Add( hForm);
    p.RenderControl (hWriter); // <-- error here stating that no Response
    object available.
    >
    I do understand that I am getting a "Response not available" error
    because there is no context associated with the newly created page
    object. Any ideas as to how I can achieve the results I am looking
    for?
    >
    -David
    sp, nobody on here has any idea on how to get this working? Or if it's
    even possible

    Comment

    Working...