mardi 9 mars 2021

How to display confirmation message when a user clicks a checkbox

I'm having issue trying to display a confirmation message when a checkbox is clicked. The confirmation box appears but doesn't perform any type of action such as displaying the text within the textbox when the user confirms OK. Any advice would do. Thanks in advance!

Here is the code.

<div>
    <asp:CheckBox ID="CheckBox1" runat="server" 
                  OnCheckedChanged="CheckBox1_CheckedChanged" 
                  OnClick="if(!confirm('Are you sure you?'))return false;" />
    <br />
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</div>

protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
    TextBox1.Text = "blah";
}



Aucun commentaire:

Enregistrer un commentaire