Hi Hazel,
Trigger click event on Button Click using jQuery.
Check this example. Now please take its reference and correct your code.
HTML
<input type="checkbox" class="ckhYesNo" value="YesNo" />Yes/No
<asp:Button ID="btnSave" Text="Save" runat="server" OnClick="OnSave" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
$('.ckhYesNo').on('click', function () {
if ($(this).is(':checked')) {
$('[id*=btnSave]').trigger('click');
}
});
});
</script>
Code
C#
protected void OnSave(object sender, EventArgs e)
{
ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Button clicked.');", true);
}
VB.Net
Protected Sub OnSave(ByVal sender As Object, ByVal e As EventArgs)
ClientScript.RegisterStartupScript(Me.GetType(), "alert", "alert('Button clicked.');", True)
End Sub