Script control is not a registered Script control

I have a page using CustomerDetails.ascx . It uses CM.ascx . Inside CM.ascx I use the AJAX Data Controls GridView with ID="gdvRecommendation" .

Sometimes, when I browse a page, I get the following exception:

Script control 'gdvRecommendation' is not a registered script control. Script controls must be registered with RegisterScriptControl () before calling RegisterScriptDescriptors ().

Parameter Name: scriptControl

  • My ScriptManager, defined on the main page, is in front of the content owner.
  • This exception is not always.
  • I use CustomerDetails.ascx user controls on other pages and it works great.

Can someone explain the problem to me and what could be the solution?

Edit:
Here is an example of using GridView in CM.ascx :

 <td valign="top" style="height: 150px;"> <div id="divCMMessage"></div> <div id='divRecommendation' style="width: 100%; display: inline; overflow: auto;"> <ADC:GridView ID="gdvRecommendation" Width="100%" runat="server" CellSpacing="0" CellPadding="3" HorizontalAlign="Right" ShowHeader="false" RowDataBoundEvent="onRowDataBound_gdvRecommendation"> <RowStyle Height="20px" /> <EmptyDataTemplate>no recommendations</EmptyDataTemplate> <EmptyDataRowStyle HorizontalAlign="Right" BorderWidth="0" /> <Columns> <ADC:GridViewImageColumn DataImageUrlField="IndImageUrl" HeaderText="" ItemStyle-Width="25px" ItemStyle-HorizontalAlign="Center"></ADC:GridViewImageColumn> <ADC:GridViewTemplateColumn HeaderText=""> <ItemTemplate> <asp:Label ID="TreatName" runat="server" Text=""></asp:Label> </ItemTemplate> </ADC:GridViewTemplateColumn> <ADC:GridViewTemplateColumn HeaderText=""> <ItemTemplate> <asp:Label ID="TreatType" runat="server" Text=""></asp:Label> </ItemTemplate> </ADC:GridViewTemplateColumn> </Columns> </ADC:GridView> </div> </td> 

CustomerDetails.ascx is inside the MultiView (at MyPage.aspx).

+5
source share
5 answers

I had a similar problem and this post helped me understand my mistakes:

Script control 'ControlName' is not a registered script control

So, you are here because you have the following error.

Script control 'ControlName' is not a registered script control. Script controls must be registered with RegisterScriptControl () before calling RegisterScriptDescriptors ().

Parameter Name: scriptControl

I myself have done quite a lot of searches about this, and there are many solutions throughout the network. Unfortunately, all this is very tailored to specific scenarios. Some people get answers, while others, like me, do not.

Answer:

You change the visibility of the control at the wrong stage in the life cycle of the page.

Description:

If you change the visibility of a control, you should always do this during or before the PreRender event. If you do this after (that is, in the asynchronous task completion handler or during PreRenderComplete), you can solve this problem.

This is not a problem for simple controls such as buttons or text boxes. But this will have adverse effects on controls such as grids.

When I talk about changing visibility, it could be any of the following situations

  • The presence of visible = false control in the early stages of the life cycle and a change to visible = true during the end handler or PreRenderComplete
  • Changing a Selected MultiView View During a Handler or PreRenderComplete
  • Any other situation where the control may not appear at earlier stages of the page life cycle, which should be visible at the last stage

Cause:

Purely from my understanding, ASP.NET does not display scripts or HTML associated with the control if it is not displayed to the user. registering the script controls mentioned in the exception seems to occur early in the life cycle. if the control is not displayed at this stage, this registration is skipped for this control. If this is seen in the last paragraph, you will get to control yourself without some relevant scripts.

Anyway, this is what I understood. Maybe I'm wrong. But if you come up with this problem, it will definitely help you check out controls that change visibility at different points in the life cycle. You can identify your specific problem by doing this and then come up with a solution on your own.

We hope this information helps someone.

A source

+9
source

I have encountered the same problem recently, the above solution did not work for me. I hid the control and then made it visible in PreRender based on some kind of status check. Hiding worked fine, but when I made it visible again, it gave me the same error.

below What worked for me -

 ScriptManager sm = ScriptManager.GetCurrent(Page); sm.RegisterScriptControl(control_name); 

Then, so that managing the visible resolves my problem.

 control_name.Visible = true; 

Hope this helps someone who has run into this problem.

+1
source

I had a similar problem with AJAX, and it was funny only in the Debug mode. In release mode, everything works fine. I have not yet concluded. You can take a picture.

0
source

In the case of RadAjaxPanel and loading UserControls, reading the answer from jhfelectric, I came up with the following solution (simple): Disable AJAX at boot (Me.EnableAJAX = False) and enable it on PreRender. Because PreRender is not called when the control is deleted, and is called after the control is added.

0
source

You can get this exception if you have a RadAjaxManager in a user control that is also inside RadAjaxManager , either directly or as a child of another user control.

0
source

Source: https://habr.com/ru/post/1386468/


All Articles