Dovberman
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="SetBoldFon t" TextAlign="Left" />
</asp:CheckBox>
What do I need to change?
Thanks
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="SetBoldFon
</asp:CheckBox>
What do I need to change?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The answer is a simple sytax error.
onCheckChanged="SetBoldFon t"
Should be: onCheckedChanged="SetBoldF ont"
onCheckChanged="SetBoldFon
Should be: onCheckedChanged="SetBoldF
ASKER
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;
}
}