OnPreRender doesn't fire and Script control 'myGridView' is not a registered script control
<p>I am using GridView of Ajax Data Controls inside MyPage.aspx.</p>

<p>This is the structure of MyPage.aspx - MyPage.aspx contains user control called Details.ascx and inside there is the 'myGridView' declaration:   </p>

<pre><code>        &lt;ADC:GridView ID=myGridView Width="100%" runat="server" CellSpacing="0" CellPadding="3" HorizontalAlign="Right" ShowHeader="false" RowDataBoundEvent="onRowDataBound_gdvRecommendation"&gt;
            &lt;RowStyle Height="20px" /&gt;
            &lt;EmptyDataTemplate&gt;No Rec&lt;/EmptyDataTemplate&gt;
            &lt;EmptyDataRowStyle HorizontalAlign="Right" BorderWidth="0" /&gt;
            &lt;Columns&gt;
                &lt;ADC:GridViewImageColumn DataImageUrlField="IndImageUrl" HeaderText="" ItemStyle-Width="25px" ItemStyle-HorizontalAlign="Center"&gt;&lt;/ADC:GridViewImageColumn&gt;
                &lt;ADC:GridViewTemplateColumn HeaderText=""&gt;
                    &lt;ItemTemplate&gt;
                        &lt;asp:Label ID="TreatName" runat="server" Text=""&gt;&lt;/asp:Label&gt;
                    &lt;/ItemTemplate&gt;
                &lt;/ADC:GridViewTemplateColumn&gt;
                &lt;ADC:GridViewTemplateColumn HeaderText=""&gt;
                    &lt;ItemTemplate&gt;
                        &lt;asp:Label ID="TreatType" runat="server" Text=""&gt;&lt;/asp:Label&gt;
                    &lt;/ItemTemplate&gt;
                &lt;/ADC:GridViewTemplateColumn&gt;
            &lt;/Columns&gt;
        &lt;/ADC:GridView&gt;
</code></pre>

<p>Under Details.ascx.cs I have:</p>

<pre><code> private ScriptManager _ScriptManager = null;
    protected override void OnPreRender(EventArgs e)
    {
        if (!this.DesignMode)
        {
            _ScriptManager = ScriptManager.GetCurrent(Page);

            if (_ScriptManager == null)
            {
                throw new HttpException("A ScriptManager control must exist on the current page.");
            }

            _ScriptManager.RegisterScriptControl(myGridView);
        }

        base.OnPreRender(e);
    }

    protected override void Render(HtmlTextWriter writer)
    {
        if (!this.DesignMode)
        {
            _ScriptManager.RegisterScriptDescriptors(myGridView);
        }

        base.Render(writer);
    }
</code></pre>

<p>I notice that as long as OnPreRender fires - everything is fine. But there are cases where OnPreRender not fires and then I get an exception (null exception because ScriptManager is not initialized).<br>
When I remove all this logic (PreRender and Render overrides) I get the exception:</p>

<pre><code>Script control 'myGridView' is not a registered script control. Script controls must be registered using RegisterScriptControl() before calling RegisterScriptDescriptors().
Parameter name: scriptControl 
</code></pre>
