This is my JavaScript.js
function checkAllCheckBox() {
var all_checkboxes = $('input[type="checkbox"]');
if (all_checkboxes.length === all_checkboxes.filter(":checked").length) {
$('#' + '<%=btnSubmit.ClientID %>').css("display", "block");
$('#' + '<%=btnNextSection.ClientID %>').attr("disabled", "disabled");
}
else {
$('#' + '<%=btnSubmit.ClientID %>').css("display", "none");
$('#' + '<%=btnNextSection.ClientID %>').attr("disabled", "");
}
}
But when i call it to my Default.aspx file , it is not working
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script src="JavaScript.js" type="text/javascript"></script>
I even created that way but it is still not working..
<script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script language="javascript" src='<%# ResolveClientUrl("JavaScript.js")%>' type="text/javascript"></script>
Any Help appreciate
Thanks
Change your method signature and pass in the btnSubmitClientId
and btnNextSectionClientId
so it would look something like this:
chkList.Attributes.Add("onclick", "checkAllCheckBox('#' + '<%=btnSubmit.ClientID %>', '#' + '<%=btnNextSection.ClientID %>')");
And then your JavaScript function would look like this:
function checkAllCheckBox(btnSubmitClientId, btnNextSectionClientId) {
var all_checkboxes = $('input[type="checkbox"]');
if (all_checkboxes.length === all_checkboxes.filter(":checked").length) {
$(btnSubmitClientId).css("display", "block");
$(btnNextSectionClientId).attr("disabled", "disabled");
}
else {
$(btnSubmitClientId).css("display", "none");
$(btnNextSectionClientId).attr("disabled", "");
}
}
仅当JavaScript代码位于<script> ... </script>
块内的ASPX页面标记内时,才可以使用<%= %>
表示法
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.