Link to home
Create AccountLog in
Avatar of Dovberman
DovbermanFlag for United States of America

asked on

How to use the checkbox event

The checkbox event does not trigger.

Code behind
 public void SetBoldFont(object sender, EventArgs e)
    {
        if (chkBold.Checked)
        {
            ctlCurrTextBox.Font.Bold = true;
        }
    }

aspx file

        <asp:CheckBox ID="chkBold" runat="server" Height="16px" Text="Bold"
             AutoPostBack="True" onCheckChanged="SetBoldFont"   TextAlign="Left" />
            </asp:CheckBox>

What do I need to change?

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Jerry Miller
Jerry Miller
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of Dovberman

ASKER

I do not need an update panel for a simple True/False control.

I added the following:

 protected void Page_Load(object sender, EventArgs e)
    {
         ctlCurrTextBox = txtBusName;
         if (Page.IsPostBack)
        {
            chkBold.Checked = true;
         }
     }

 public void SetBoldFont(object sender, EventArgs e)
    {
        if (chkBold.Checked)   // This block is never reached.
        {
            ctlCurrTextBox.Font.Bold = true;
        }
    }
The answer is a simple sytax error.

onCheckChanged="SetBoldFont"

Should be: onCheckedChanged="SetBoldFont"