Free Resources from FMS

Additional Resources

 

Thank you! Thank you! I just finished reading this document, which was part of a link in the recent Buzz newsletter. I have printed it for others to read, especially those skeptical on the powers of Access and its capabilities.

Darren D.

 

Free Catalog

 

Client side onclick handler workaround for ASP:CHECKBOX

Provided by:  FMS Development Team

If you need to add extra JavaScript code or validation to the onclick event handler of the checkbox that is rendered as a result of the ASP:CHECKBOX, you will need to use the html input control instead as a workaround. In the following code, the client side JavaScript function confirmCheck needs to be run before the form is submitted. This is achieved by using the INPUT tag instead of the ASP:CHECKBOX tag. Any server side event handlers can be handled by defining the server side event handler. In the following example, chkSignedOff_CheckedChanged will handle onserverchange event.

<INPUT id="chkSignedOff" onclick="confirmCheck();" type="checkbox" value="Accept Form" name="chkClient" runat="server" onserverchange="chkSignedOff_CheckedChanged">
 

<script language="JavaScript">
function confirmCheck()
{
  //Add client side JavaScript / validation code here

}

</script>

Code behind:

Protected Sub chkSignedOff_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
  '''Add server side code here
End Sub

REPLACES the following with client script:

<asp:checkbox id="chkSignedOff2" runat="server" Text="Accept Form" visible="false" AutoPostBack="True">

</asp:checkbox>

Code behind:

Private Sub chkSignedOff2_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles chkSignedOff2.CheckedChanged
  '''Add server side code here
End Sub

Return to the tips page