A situation has arisen where a checkbox is set to automatically post when it is changed.
The auto post functionality is functioning properly for both checked and unchecked states. However, the desire is to have a dialog box pop up to confirm before each event occurs.
Currently, the popup box does appear when the checkbox is checked.
Unfortunately, there is an issue with getting a confirmation dialog to pop up when the checkbox is unchecked.
Query: How can I implement a dialog box for the uncheck event using only client-side code?
<asp:CheckBox ID="CurrentCheckBox" runat="server" AutoPostBack="True" Checked='<%# Bind("BDValue") %>' OnCheckedChanged="SharedFunctionForThisCheckBox_CheckedChanged" onclick="checkBoxConfirmClick(this);" />
<script type="text/javascript">
function checkBoxConfirmClick(elementRef) {
if (elementRef.checked) {
if (window.confirm('Are you sure?') == false)
elementRef.checked = false;
}
}
</script>