473,396 Members | 1,879 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Enabling/Disabling Form controls with checkbox click.

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_Checke dChanged);

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.

Nov 19 '05 #1
3 1589
Have you set the AutoPostBack property of the CheckBox to true?
Otherwise it won't post back on checking it.
"Assimalyst" <c_******@hotmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
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_Checke dChanged);

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.

Nov 19 '05 #2
Hi Assimalyst
perhaps you need to set autopost back property of checkbox to true.

Also you can cut short your long statements by following lines, if your routine is just intend to implement toggle.
titleCboBx.Enabled = !titleCboBx.Enabled
fNameTxtBx.Enabled = !fNameTxtBx.Enabled


Regards
Jignesh Desai - MVP
Blogs @ http://dotnetjini.jigneshdesai.com/Blogs/default.aspx
..NET Training Programs : http://dotnetjini.jigneshdesai.com/Training.aspx

"Assimalyst" <c_******@hotmail.com> wrote in message news:11*********************@z14g2000cwz.googlegro ups.com...
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_Checke dChanged);

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.

Nov 19 '05 #3
Thankyou both, problem solved.

Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ashish Shridharan | last post by:
Hi All, Has anyone ever tried disabling a checkbox or a radiobutton web server control in netscape ? While a textbox and a button control renders disabled, .NET adds the disabled attribute to...
6
by: ML.Steve | last post by:
Hi, There are lots of posts on this subject but after a couple of hours of going though them I still can't get a number of fields to be disabled when a checkbox is ticked. Basically I have a...
3
by: Leo J. Hart IV | last post by:
OK, here's another question for the experts: I am building a multi-step (3 steps actually) form using a panel for each step and hiding/displaying the appropriate panel/panels depending on which...
3
by: Tumurbaatar S. | last post by:
I'm trying to dynamically hide/show a HTML table server control. My form contains one CheckBox control and its AutoPostBack set to true. The Checked value of this box controls whether to show or...
4
by: Philip Wagenaar | last post by:
I have made a form with a tab that containts groupboxes and those contain checkboxes. When I run the application sometimes the outlining for some groupboxes are not shown, if I switch tabs and...
7
by: John Meyer | last post by:
I have a program where I have to enable or disable a list box based upon a radio button. Is there an "enabled" property on select boxes?
2
by: mitzie | last post by:
Is it possible to enable and disable check box of active record using a continuous form? The problem with what I have done is if user entered multiple records, then clicked 1st option box, all...
0
by: morathm | last post by:
I have a windows client database management application written in C# that connects to remote web services to do all the heavy work. The thin-client app uses strong typed datasets, all maintained at...
1
by: allamaria | last post by:
I am creating a form in Access, in the form there is a checkbox and some fields. I want to set the checkbox so, that if the user clicks on it, the fields should be enabled, if the checkbox has not...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.