Enabling/Disabling Form controls with checkbox click.

A

Assimalyst

Hi I am attempting to enable/disable webform controls depending on
whether a checkbox is checked or not.

I have an event handler for when the checkbox checked is changed

this.addNewSurgeonChkBx.CheckedChanged += new
System.EventHandler(this.addNewSurgeonChkBx_CheckedChanged);

And the code called by this is:

private void addNewSurgeonChkBx_CheckedChanged(object sender,
System.EventArgs e)
{
if (addNewSurgeonChkBx.Checked == true)
{
titleCboBx.Enabled = true;
fNameTxtBx.Enabled = true;
lNameTxtBx.Enabled = true;
surgeonNameCboBx.Enabled = false;
}
else
{
titleCboBx.Enabled = false;
fNameTxtBx.Enabled = false;
lNameTxtBx.Enabled = false;
surgeonNameCboBx.Enabled = true;
}
}

But when I load the page and check the checkbox nothing happens, the
disabled controls remain disabled, the enabled ones remain enabled. Any
ideas why?

Thanks.
 
G

Grant Merwitz

Have you set the AutoPostBack property of the CheckBox to true?
Otherwise it won't post back on checking it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top