asp.net - Check if ASPX checkbox is checked with javascript -
how can check if checkbox checked or not on page load javascript? none of codes worked:
<asp:checkbox runat="server" id="chkemailconsent" checked='<%# bool.parse(eval("emailconsent").tostring()) %>' enabled="false" /> document.getelementbyid("<%= chkemailconsent.clientid %>") document.getelementbyid("ctl00_cphglobalcontent_formview1_chkemailconsentid")
i using same name controls both server , client side add clientidmode="static". way not have use <%= stuff control name.
<asp:checkbox runat="server" clientidmode="static" id="chkemailconsent" checked='<%# bool.parse(eval("emailconsent").tostring()) %>' enabled="false" /> <script> // note, works because check value after control. // otherwise need in function or alert(document.getelementbyid("chkemailconsent").checked) </script>
Comments
Post a Comment