Script controls may not be registered before PreRender

2 posts, 0 answers
  1. Graeme
    Graeme  avatar
    2 posts
    Member since:
    Aug 2012

    Posted 09 Mar 2012 Link to this post

    Ok, I'm at the bottom of the pit of despair!
    Have tried for days to resolve this problem, so maybe hoping someone here can help. I've searched the web and tried all the advice given, to no avail. Here is the problem.

    I built a local project with RAD grid, cloud, combos etc and it worked fine.  However, when I integrated it into out CMS, the problems started.  The man error message is:

    Script controls may not be registered before PreRender


    The problem is something to do with this piece of code:
    <telerik:RadScriptManager ID="RadScriptManager1" EnableHandlerDetection="false" runat="server">
    </telerik:RadScriptManager>


    The pages where I've tried this :
    1. The master page
    2. The ascx page

    Doesn't matter where I position this line of code, I still get either the above error message.  I've also tried these 2 different code blocks (not at the same time obviously) in the code behind of the ascx page:

      
    protected override void OnInit(EventArgs e)
    {
        if (ScriptManager.GetCurrent(this.Page) == null)
        {
            ScriptManager scriptManager = new ScriptManager();
            scriptManager.ID = "myScriptManager";
            scriptManager.EnablePartialRendering = true;
            this.Page.Form.Controls.Add(scriptManager);
        }
        base.OnInit(e);
    }
     
    protected override void OnPreRender(EventArgs e)
    {
        if (ScriptManager.GetCurrent(this.Page) == null)
        {
            ScriptManager scriptManager = new ScriptManager();
            scriptManager.ID = "myScriptManager";
            scriptManager.EnablePartialRendering = true;
            this.Page.Form.Controls.Add(scriptManager);
        }
        base.OnPreRender(e);
    }

    Here is the stack trace:
    [InvalidOperationException: Script controls may not be registered before PreRender.]
       System.Web.UI.ScriptControlManager.RegisterScriptControl(TScriptControl scriptControl) +348689
       System.Web.UI.ScriptManager.RegisterScriptControl(TScriptControl scriptControl) +66
       Telerik.Web.UI.RadWebControl.RegisterScriptControl() +42
       Telerik.Web.UI.RadWebControl.ControlPreRender() +15
       Telerik.Web.UI.RadFormDecorator.ControlPreRender() +464
       Telerik.Web.UI.RadWebControl.OnPreRender(EventArgs e) +22
       System.Web.UI.Control.PreRenderRecursiveInternal() +80
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842


    I'm pretty much as my wits end with this. Any ideas Telerik, community?
    Many thanks,
    Alan
  2. jumpstart
    jumpstart avatar
    479 posts
    Member since:
    Nov 2011

    Posted 13 Mar 2012 Link to this post

    Alan:

    I'm not sure if you've seen this Telerik forum thread yet, but it has some useful insights from Pavlina in Telerik Admin:

    Error: Script controls may not be registered before PreRender

    Hope this helps!
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top