AJAX PostBack: Script controls may not be registered after PreRender.

6 posts, 0 answers
  1. Brian Mains
    Brian Mains avatar
    485 posts
    Member since:
    Oct 2008

    Posted 19 May 2011 Link to this post

    Hello,

    OK, so I have a page that has a radgrid and a form.  When creating a new record via the form and rebinding the grid, it works fine.  When initially binding the grid, it works fine.  Only when clicking a delete button in the grid, handling the custom command, and rebinding, do I get this error.

    On the form, there are radtextbox, radcombobox, radspell, and other controls.  I noticed the RadSpell.CreateChildCOntrols in the stacktrace... does that mean that's where the error is?  I also see a reference to ASP.views_shared_header_ascx.__Render__control1, which is a user control and has some controls/AJAX in it.

    Also, I'm binding on PreRender - this is not an issue for the rest of the app that does the same thing; and in this page, it only happens on this one spot, not in the other two spots, which are bound on prerender...

    Why would this error be happening?

    Thanks.


    at System.Web.UI.ScriptControlManager.RegisterScriptControl[TScriptControl](TScriptControl scriptControl)
    at Telerik.Web.UI.RadWebControl.RegisterScriptControl()
    at Telerik.Web.UI.RadWebControl.ControlPreRender()
    at System.Web.UI.Control.PreRenderRecursiveInternal()
    at System.Web.UI.Control.AddedControl(Control control, Int32 index)
    at Telerik.Web.UI.RadSpell.CreateChildControls()
    at System.Web.UI.Control.EnsureChildControls()
    at System.Web.UI.Control.FindControl(String id, Int32 pathOffset)
    at Telerik.Web.ChildControlHelper.FindControlRecursive(String ID, Control root)
    at Telerik.Web.ChildControlHelper.FindControlRecursive(String ID, Control root)
    at Telerik.Web.ChildControlHelper.FindControlRecursive(String ID, Control root)
    at Telerik.Web.ChildControlHelper.FindControlRecursive(String ID, Control root)
    at Telerik.Web.ChildControlHelper.FindControlRecursive(String ID, Control root)
    at Telerik.Web.ChildControlHelper.FindControlRecursive(String ID, Control root)
    at Telerik.Web.ChildControlHelper.FindControlRecursive(String ID, Control root)
    at Telerik.Web.ChildControlHelper.FindControlRecursive(String ID, Control root)
    at Telerik.Web.ChildControlHelper.FindControlRecursive(String ID, Control root)
    at Telerik.Web.ChildControlHelper.FindControlRecursive(String ID, Control root)
    at Telerik.Web.ChildControlHelper.FindControlRecursive(String ID, Control root)
    at Telerik.Web.ChildControlHelper.FindControlRecursive(String ID, Control root)
    at Telerik.Web.UI.RadScriptBlock.GetAjaxSettingForCurrentInitiator(RadAjaxManager currentAjaxManager)
    at Telerik.Web.UI.RadScriptBlock.IsForCurrrentInitiator(Control controlToCheck, RadAjaxManager currentAjaxManager)
    at Telerik.Web.UI.RadScriptBlock.IsInUpdatedControls(Control controlToCheck, RadAjaxManager currentAjaxManager)
    at Telerik.Web.UI.RadScriptBlock.Render(HtmlTextWriter writer)
    at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
    at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
    at System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer)
    at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
    at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
    at System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer)
    at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
    at ASP.views_shared_header_ascx.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\hbweb\538e2744\52ba1acc\App_Web_header.ascx.639c3968.q1sqgwkt.0.cs:line 0
    at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
    at Telerik.Web.UI.RadAjaxPanel.RenderChildren(HtmlTextWriter writer)
    at Telerik.Web.UI.RadAjaxPanel.RenderContents(HtmlTextWriter writer)
    at Telerik.Web.UI.RadAjaxPanel.Render(HtmlTextWriter writer)
    at Telerik.Web.UI.ControlRenderer.Render(HtmlTextWriter writer)
    at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
    at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
    at System.Web.UI.UpdatePanel.RenderChildren(HtmlTextWriter writer)
    at System.Web.UI.UpdatePanel.Render(HtmlTextWriter writer)
    at Telerik.Web.UI.OurUpdatePanel.Render(HtmlTextWriter writer)
    at System.Web.UI.PageRequestManager.RenderFormCallback(HtmlTextWriter writer, Control containerControl)
    at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
    at System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer)
    at System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer)
    at System.Web.UI.HtmlFormWrapper.System.Web.UI.IHtmlForm.RenderControl(HtmlTextWriter writer)
    at System.Web.UI.PageRequestManager.RenderPageCallback(HtmlTextWriter writer, Control pageControl)
    at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
    at System.Web.UI.Page.Render(HtmlTextWriter writer)   
  2. Radoslav
    Admin
    Radoslav avatar
    1564 posts

    Posted 20 May 2011 Link to this post

    Hi Brian,

    Based on the supplied information, it is hard to determine what is causing the unwanted behavior at your end. Could you please send us a small runnable project which demonstrates the described issue. You could open a formal support ticket from your Telerik account and attach a ZIP file there.
    Thus we will be able to gather more details about your scenario and provide you with more to-the-point answer.
    Additionally could you please try using the advanced data-binding and let me know if the issue still exists.

    Best wishes,
    Radoslav
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Hatim
    Hatim avatar
    3 posts
    Member since:
    Jun 2012

    Posted 11 Jun 2013 Link to this post

    Helllo, 

    I have the same probleme when i create dynamicly "telerik controls"  and just with telerk controls
    and it give me this error, after a postback
    telerik script controls may not be registered after prerender

    did you find out the solution?

    Best regards
  5. Radoslav
    Admin
    Radoslav avatar
    1564 posts

    Posted 13 Jun 2013 Link to this post

    Hi Hatim,

    Could you please post the code which you use to create the controls dynamically?

    Looking forward for your reply.

    Regards,
    Radoslav
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  6. Hatim
    Hatim avatar
    3 posts
    Member since:
    Jun 2012

    Posted 17 Jun 2013 Link to this post

     i use the telerik controls because i need checkbox with tri-state

    protected override void OnInit(EventArgs e)
            {
                base.OnInit(e);
                if (Session["PanelGroup"] != null)
                {
                    Panel1.Controls.Clear();
                    Panel PanelGroup = Session["PanelGroup"] as Panel;
                    Panel1.Controls.Add(PanelGroup);
                }
                else
                   {
           
                    Panel panelGr = new Panel();
                    panelGr.ID = gr.Id.ToString();
                    panelGr.GroupingText = gr.Label;

                   foreach (var q in listQualifByGr)
                   {
                        RadButton btnToggle = new RadButton();
                        btnToggle.ID = "btnToggle_" + q.Id;
                        
                        btnToggle.ButtonType = RadButtonType.ToggleButton;
                        btnToggle.ToggleType = ButtonToggleType.CustomToggle;
                        btnToggle.Skin = "WebBlue";
                        btnToggle.Text = q.Label;
                        btnToggle.Value = q.Id.ToString();
                       btnToggle.AutoPostBack = false;
                        RadButtonToggleState rbts = new RadButtonToggleState();
                      rbts.PrimaryIconCssClass = "rbToggleCheckbox";
                        rbts.Value = "0";
                        btnToggle.ToggleStates.Add(rbts);
                        RadButtonToggleState rbts3 = new RadButtonToggleState();
                        rbts3.PrimaryIconCssClass = "rbToggleCheckboxChecked";
                        rbts3.CssClass = "rbSkinnedButtonChecked";
                        rbts3.Value = "1";
                        btnToggle.ToggleStates.Add(rbts3);
                        panelGr.Controls.Add(btnToggle);
                    }
                    Panel_GroupQualif.Controls.Add(panelGr);

                Panel1.Controls.Add(Panel_GroupQualif);
                Session["PanelGroup"] = Panel_GroupQualif;
    }
    }
  7. Radoslav
    Admin
    Radoslav avatar
    1564 posts

    Posted 19 Jun 2013 Link to this post

    Hi Hatim,

    You cannot store the RadControls into the Session and on the later post back to get them from there. In your case you need to add them every time on OnInit event:
    protected override void OnInit(EventArgs e)
    {
         base.OnInit(e);
     
         Panel panelGr = new Panel();
         panelGr.ID = gr.Id.ToString();
         panelGr.GroupingText = gr.Label;
     
         foreach (var q in listQualifByGr)
         {
             RadButton btnToggle = new RadButton();
             btnToggle.ID = "btnToggle_" + q.Id;
     
             btnToggle.ButtonType = RadButtonType.ToggleButton;
             btnToggle.ToggleType = ButtonToggleType.CustomToggle;
             btnToggle.Skin = "WebBlue";
             btnToggle.Text = q.Label;
             btnToggle.Value = q.Id.ToString();
             btnToggle.AutoPostBack = false;
             RadButtonToggleState rbts = new RadButtonToggleState();
             rbts.PrimaryIconCssClass = "rbToggleCheckbox";
             rbts.Value = "0";
             btnToggle.ToggleStates.Add(rbts);
             RadButtonToggleState rbts3 = new RadButtonToggleState();
             rbts3.PrimaryIconCssClass = "rbToggleCheckboxChecked";
             rbts3.CssClass = "rbSkinnedButtonChecked";
             rbts3.Value = "1";
             btnToggle.ToggleStates.Add(rbts3);
             panelGr.Controls.Add(btnToggle);
       }
      Panel_GroupQualif.Controls.Add(panelGr);
      Panel1.Controls.Add(Panel_GroupQualif);
    }


    Regards,
    Radoslav
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017