加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net – 脚本控件不是注册的脚本控件

发布时间:2020-12-16 07:23:16 所属栏目:asp.Net 来源:网络整理
导读:我有一个使用CustomerDetails.ascx的页面.它使用CM.ascx.在CM.ascx中,我使用 AJAX Data Controls GridView,ID =“gdvRecommendation”. 有时当我浏览页面时,我得到以下异常: Script control ‘gdvRecommendation’ is not a registered script control. Scr
我有一个使用CustomerDetails.ascx的页面.它使用CM.ascx.在CM.ascx中,我使用 AJAX Data Controls GridView,ID =“gdvRecommendation”.

有时当我浏览页面时,我得到以下异常:

Script control ‘gdvRecommendation’ is not a registered script control. Script controls must be registered using RegisterScriptControl() before calling RegisterScriptDescriptors().

Parameter name: scriptControl

>我的ScriptManager在内容占位符之前的母版页中定义.
>此异常并不总是发生.
>我在其他页面中使用CustomerDetails.ascx用户控件,效果很好.

任何人都可以解释我的问题,解决方案是什么?

编辑:
这是CM.ascx中的GridView用法:

<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位于MultiView内(在MyPage.aspx上).

解决方法

我自己也有类似的问题,这篇文章帮助我理解了我的错误:

Script control ‘ControlName’ is not a registered script control

So you’re here because you got the following error.

Script control ‘ControlName’ is not a registered script control. Script controls must be registered using RegisterScriptControl() before calling RegisterScriptDescriptors().

Parameter name: scriptControl

I myself have done a fair bit of googling on this,and there are many
solutions given all over the net. unfortunately these are all very
scenario specific solutions. Some people get their answers,and the
others,like me,don’t.

Answer:

You are changing the visibility of a control at the wrong stage of the
page life cycle.

Description:

If you are changing the visibility of a control,you should always do
it during,or before the PreRender event. If you do it after (i.e. in
a End handler of an async task or during PreRenderComplete) you might
run in to this issue.

This is not an issue for simple controls such as buttons or text
boxes. But it will have adverse effects on controls such as grids.

When I say changing the visibility it could be any one of the
following situations

?

>在生命周期的早期阶段具有控件的visible = false,并在结束处理程序或PreRenderComplete期间更改为visible = true
>在结束处理程序或PreRenderComplete期间更改MultiView的选定视图
>在页面生命周期的早期阶段可能看不到控件的任何其他情况,这些阶段设置为在后一阶段可见

Reason:

Purely
from my understanding,ASP.NET does not render the scripts or the HTML
related to a control if it is not being shown to the user. The
registering of script controls which is mentioned in the exception
seem to happen during an early stage of the life cycle. if the control
is not visible at this stage,this registration is skipped for that
control. If it’s made to be visible at a latter point,you get
yourself a control without some of the relevant scripts.

Anyway this is what I have understood. I may be wrong. But if you come
across this issue,it will definitely help you to check for controls
which are changing visibility at different points of the life cycle.
You will be able to identify your specific problem by doing this and
then come up with a solution on your own.

Hope this information helps some one.

Source

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读