Link to home
Start Free TrialLog 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
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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"