Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 464
Nevin Mathai Avatar asked Jan 03 '10 19:01

Nevin Mathai


People also ask

Can we use more than one ScriptManager in your web page?

The ScriptManagerProxy works in a similar fashion as the ScriptManager control. You can have multiple ScriptManagerProxy item in a page. This helps you to add custom scripts or a Webservice proxy only when needed.

How many ScriptManager control can be added on?

A page can contain only one ScriptManager control in its hierarchy.

Where do I put the ASP ScriptManager?

I would put the ScriptManager at the top of the Master page outside of any Multi-View. The ScriptManager is a what is used by the Microsoft controls to provide AJAX functionality.


2 Answers

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

like image 94
Eilon Avatar answered Sep 22 '22 18:09

Eilon


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.

like image 37
citronas Avatar answered Sep 18 '22 18:09

citronas