I have a CheckBox control within a asp:Panel like below:
<asp:Panel ID="chk" runat="server" Visible="false" CssClass="checkbox checkbox-primary checkbox-single">
<asp:CheckBox runat="server" ID="valCheck" />
</asp:Panel>
I need to be able to check to see if this CheckBox is being checked or not then I would send 0 or 1 to a function that will do some more stuff and when comes back based on the value, if it's more than 0 it will display a checked check box. I need to use this value, because I also have some other types of inputs as well which I set their value based on the value coming back from another call.
var checking = false;
function saveCheckBoxData(obj, id, inputType) {
if (checking) return;
checking = true;
var date = $("#MainContent_date").val();
var column = $(obj).attr("column");
var dataFieldId = $(obj).attr("dataFieldId ");
var shift = $(obj).attr("shift");
var val = 0;
//if ($("#valCheck").is(':checked')) {
// val = 1;
//}
//if ($('#valCheck').prop('checked')) {
// val = 1;
//}
//if ($('#valCheck').attr("checked")) {
// val = 1;
//}
SaveInput(dataFieldId , shift, inputType, date, column, id, val);
}
When I call SaveInput function, I need to either pass 0 (if checkbox is not checked) or 1 (when it's checked). The lines I've commented out did not work!
Any feedback would be greatly appreciated!
#valCheckasidto yourcheckbox$('<%=valCheck.ClientID %>').is(':checked')if you have written the js code in same aspx page.ClientIDMode="static"in your checkbox field and then try.