I have the following Jquery running in an aspx page without the use of a master page. The markup, with script is below. It works just fine.
<body>
<form id="form1" runat="server">
<div>
<asp:CheckBox ID="chkAll" runat="server" Text="Check All" /><br />
<asp:CheckBoxList ID="cbList" runat="server">
</asp:CheckBoxList>
</div>
</form>
Here is the script
<script src="Scripts/jquery-1.7.2.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#chkAll').click(
function () {
$("INPUT[type='checkbox']").attr('checked', $('#chkAll').is(':checked'));
});
});
</script>
Here is the markup for the page i created using a master page. The master page only has the reference to the jquery file in the header in the HeadContent placeholder. Needless to say it doesnt work in the master page scenario. Why is the question
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
The identical script from above is placed here
</asp:Content>
And here is the placeholder content markup
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
<div>
<asp:CheckBox ID="chkAll" runat="server" Text="Check All" /><br />
<asp:CheckBoxList ID="cbList" runat="server">
</asp:CheckBoxList>
</div>
</asp:Content>
Using
ClientIDMode="Static"on your control should allow you to reference it by the name you assigned.