jQuery in Asp.Net Master and Content page

The jQuery is all executed clientside, and your masterpages and childpages are assembled serverside and only when you view the page the server will put all the master or children pieces together and send the completed HTML to the browser, only then will the browser start executing Javascript . So, ensure that if you have already included jQuery in your master page, don't include this in your content page.

Master page:

<head runat="server"> <title></title> <script src="Scripts/jquery-1.3.2.js" type="text/javascript"></script> <asp:ContentPlaceHolder ID="HeadContent" runat="server"> </asp:ContentPlaceHolder> </head>

Content page:

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"> <script type="text/javascript"> $(document).ready(function () { $("[id$=myButton]").click(function () { alert("This is from content page !"); }); }); </script> </asp:Content>

Button code:

<asp:Button ID="myButton" runat="server" Text="Button" />