Only one instance of a ScriptManager can be added to the page

吃可爱长大的小学妹 提交于 2020-01-01 09:16:26

问题


I had an ASP UpdatePanel to update a gridview which worked fine, now I wanted to also use AjaxControlToolkit for some of the controls in there, but after wiring up everything when I run I get an error

  "Only one instance of a ScriptManager can be added to the page."

inspite of the fact that I commented off the ASP ScriptManager and am using the toolkitscriptmanager. however please note that I am still using the ASP UpdatePanels.

 <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
                    </asp:ToolkitScriptManager>

                  <!-- <asp:ScriptManager ID="ScriptManager1" runat="server">
                                 </asp:ScriptManager>-->

Any ideas as to what might be going wrong here?


回答1:


You're using an HTML comment to hide an ASP.NET server tag. Use a server comment instead:

<%-- <asp:ScriptManager ID="ScriptManager1" runat="server"> 
                             </asp:ScriptManager> --%>

ASP.NET ignores HTML comments just like it ignores all tags without a runat="server" on them or that don't start with <%.




回答2:


The original error message tells you that you try to have multiple ScriptManger objects. Such a scenario would be present if you use a ScriptManager in the MasterPage and in a individual page that inherits the master page. To avoid this, there is <Asp:ScriptManagerProxy> which works as another ScriptManager, though it only passes the calls to the ScriptManager object in the masterpage.



来源:https://stackoverflow.com/questions/1996095/only-one-instance-of-a-scriptmanager-can-be-added-to-the-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!