views:

3283

answers:

5

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

A: 

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

jmein
+4  A: 

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.

achinda99
+1  A: 

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!

Tomas Lycken
I want to use the Ajax Controls
If you r e a l l y want to use Ajax Controls, I'm not going to stop you. But if what you want is to get some of the f u n c t i o n a l i t y that Ajax Controls offer, I think you will be surprised to see that it's even easier to do the same thing - better - with jQuery.
Tomas Lycken
Using ajax controls is good but there may be instances when jquery would be very useful. If you have never used it before I would highly recommend checking it out. If you are going to be writing any javascript at all it is a life saver.
jmein
+4  A: 

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>
Bullines
What if I'm just using one of the Ajax controls in the content page...do I still need the ScriptManagerProxy control on the control page?
If you just want to use ASP.NET AJAX controls on your content page, then no need for the ScriptManagerProxy.
Bullines
A: 

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.

Andrew Lundgren
this should be changed to a comment on Tomas Lycken's answer
MGOwen