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

2

8

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?

Warnerwarning answered 3/1, 2010 at 19:55 Comment(0)
B
13

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 <%.

Brawl answered 3/1, 2010 at 19:57 Comment(2)
An easy way to comment in the web form (and avoid such errors) is to use the hotkey CTRL+K,C to comment and CTRL+K,U to uncomment. In code-behind, you can have the cursor anywhere on a line to comment/uncomment; in web form, your highlighted selection must begin and end where you want to comment.Neslund
I use these shortcut keys all the time! It's super quick to select multiple lines (or, as you say, select nothing at all) and be able to comment out some code. Great for debugging mysteries where you want to temporarily eliminate some code or markup.Brawl
A
7

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.

Antonelli answered 3/1, 2010 at 22:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.