Search code examples
asp.net.netwebformstelerik

Script controls must be registered using RegisterScriptControl() before calling RegisterScriptDescriptors(). after upgrading to .Net 4.5


I got this error after upgrading to .Net 4.5 in my asp.net webforms application. Using Telerik.Web.UI 2011.1.315.35

Error: Script control 'Grid0' is not a registered script control. Script controls must be registered using RegisterScriptControl() before calling RegisterScriptDescriptors().

.aspx snipit

  <table class="noprint" id="tblSpace" border="0" cellpadding="2" cellspacing="0"  
    style="margin-top: 0px;" width="100%" height="30px" runat="server">
    <tr>
    <td>&nbsp</td></tr>
</table>
<table id="tblHeading" border="0" cellpadding="2" cellspacing="0"  
    style="margin-top: 0px;" width="100%" runat="server" enableviewstate="true">
</table>
<table id="tblResults1" border="0" cellpadding="2" cellspacing="0" 
    style="margin-top: 0px; margin-left:2px; overflow:visible; height:auto;" width="100%" runat="server" RegisterWithScriptManager="true">
</table>
<asp:Timer ID="Timer1" runat="server" Interval="1000" Enabled="false"></asp:Timer> 
</ContentTemplate>

.cs snipit

  private StringWriter GetReportHtml()
    {

        StringWriter tw = new StringWriter();
        Html32TextWriter hw = new Html32TextWriter(tw);
        hw.Write("<html><head>");
        hw.Write("</head><body>");


        //This render does not error
        tblHeading.RenderControl(hw);

        if (tblResults1 != null)
        {
            hw.WriteBreak();
            //This render errors 
            tblResults1.RenderControl(hw);
        }

        hw.Write("</body></html>");

        return tw;
    }

Solution

  • Changed this to false, the script control is being disposed

    key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />