Billy
Billy

Reputation:

Ajax Script Manager and Master Pages

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?)

Upvotes: 9

Views: 12663

Answers (5)

Andrew Lundgren
Andrew Lundgren

Reputation: 11

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.

Upvotes: 1

Bullines
Bullines

Reputation: 5696

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>

Upvotes: 13

Josh Mein
Josh Mein

Reputation: 28645

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

Upvotes: 1

achinda99
achinda99

Reputation: 5078

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.

Upvotes: 6

Tomas Aschan
Tomas Aschan

Reputation: 60624

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!

Upvotes: 1

Related Questions