RenderControl causes The ScriptManager must appear before any controls that need it.

Last post 11-05-2009 12:35 AM by kwanann. 3 replies.

Sort Posts:

  • RenderControl causes The ScriptManager must appear before any controls that need it.

    11-04-2009, 1:15 PM
    • Member
      2 point Member
    • tgaughan
    • Member since 08-25-2009, 4:19 PM
    • Posts 6

    I'm loading a user control in a service handler (.ashx).  In the user control I have a few collapseable panel extenders, a filter text box extender and a modal popup extender.

    We're using a master page that has a ScriptManager defined in the layout.

    Here's some code:

    public void ProcessRequest(HttpContext context)
    {

       HtmlTextWriter writer = new HtmlTextWriter(new System.IO.StringWriter());

       MyNamespace.Web.PageBase pageBase = new MyNameSpace.Web.Base.PageBase();
       pageBase.CancelVerifyRenderingInServerForm = true;
       pageBase.EnableEventValidation = false;

       ItemRatesCtl itemRatesCtl = (ItemRatesCtl)pageBase.LoadControl("/Booking/Rates/ItemRatesCtl.ascx");
       itemRatesCtl.RenderControl(writer);

    }

    On the RenderControl execution:

    The control with ID 'CollapsiblePanelExtenderRentBreakdown' requires a ScriptManager on the page. The ScriptManager must appear before any controls that need it.

    I;ve tried putting a ScriptManagerProxy control in the user control and registering the service (which BTW get's called on page load).  That does not help...same error.  I tried registering the extenders with the Master ScriptManager when the control loads but then it tells me that the controls are already registered.

    We're doing this type of thing a bunch of places but this is the fist that has a control using AJAX toolkit extenders.

    Thanks,

    Tom

  • Re: RenderControl causes The ScriptManager must appear before any controls that need it.

    11-04-2009, 5:40 PM
    • Contributor
      2,547 point Contributor
    • kwanann
    • Member since 02-05-2009, 7:59 AM
    • SG
    • Posts 497

    i'm quite confused here, how exactly are you loading the control via ashx?


    note that in the ashx processrequest, it is an entirely new request i.e even if there's a script manager registered in the parent page, it is not carried over here.


    one way, not sure if it works is to add a scriptmanager inside your processrequest as well.

    MVP ASP.NET C#
    View my blog @ http://jefferytay.wordpress.com
  • Re: RenderControl causes The ScriptManager must appear before any controls that need it.

    11-04-2009, 7:33 PM
    • Member
      2 point Member
    • tgaughan
    • Member since 08-25-2009, 4:19 PM
    • Posts 6

    Sorry, I left out the Write which would spew out the control:

    context.Response.ContentType = "text/html";
    context.Response.Write(writer.InnerWriter.ToString());

    So if I have to create a new ScriptManager in the ProcessRequest, I'll have to register each Ajax toolkit control extender and the control that it's extending?

    How can I create the ScriptManager control?

    or...

    Can I use a ScriptManagerProxy control that is on the control that I'm rendering?

    Thanks...

  • Re: RenderControl causes The ScriptManager must appear before any controls that need it.

    11-05-2009, 12:35 AM
    Answer
    • Contributor
      2,547 point Contributor
    • kwanann
    • Member since 02-05-2009, 7:59 AM
    • SG
    • Posts 497

    was lookin at the code for controltoolkit, don't think there's a way to overwrite this.


    the only way i can think of is to create a page object, assign controls to it, then render this. but i'm not sure if this works out for you

    MVP ASP.NET C#
    View my blog @ http://jefferytay.wordpress.com
Page 1 of 1 (4 items)