I'm building a new website and want to use Ajax controls.
Do I need to put a ScriptManager control on both the MasterPage and on each content page? or Just on the MasterPage?(or just on the content page?)
I'm building a new website and want to use Ajax controls.
Do I need to put a ScriptManager control on both the MasterPage and on each content page? or Just on the MasterPage?(or just on the content page?)
You are only allowed to have one ScriptManager. You can have it on either. Having it on the master page saves you the task of adding it on content pages. However, writing custom script within the script manager is only possible if you have it in the content pages. As stated below, having two ScriptManagers throws an error on loading the page.
Content pages or MasterPages can only have one ScriptManager control on them. If you have a ScriptManager control on your MasterPage, you can drop a ScriptManagerProxy control onto your content pages to use any given specific ASP.NET AJAX functionality like this, for example:
<asp:Content ID="Content1" ContentPlaceHolderID="BodyContent" runat="server">
<asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server">
<Services>
<asp:ServiceReference Path="~/MyWebServices/YourCoolWebService.asmx" />
</Services>
</asp:ScriptManagerProxy>
<%-- more content stuff goes here --%>
<asp:Content>
You are only allowed to have one ScriptManager. You can have it on either. Having it on the master page saves you the task of adding it on content pages. However, writing custom script within the script manager is only possible if you have it in the content pages. As stated below, having two ScriptManagers throws an error on loading the page.
Just the master page. Unless you are going to have custom scripts like mentioned above, I would recommend just putting it on the Master Page so that you do not have to put it on every page that is going to use an ajax control.
If you have it on both it throws an error saying that you can only have one scriptmanager/page
What functionality are you looking for? Chances are you will be able to do just as much or more, but with a much lighter footprint, better performing code and better control over what's actually happening if you use jQuery instead. Check it out!
jQuery vs ASP.NET AJAX is not an "either-or question". Although they have overlapping functionality, they are very diff, and I use both daily depending on task. Use jQuery when possible - but MS AJAX adds a ton of ASP.NET convenience functionality.
© 2022 - 2024 — McMap. All rights reserved.