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.addNewSurg eonChkBx.Checke dChanged += new
System.EventHan dler(this.addNe wSurgeonChkBx_C heckedChanged);
And the code called by this is:
private void addNewSurgeonCh kBx_CheckedChan ged(object sender,
System.EventArg s e)
{
if (addNewSurgeonC hkBx.Checked == true)
{
titleCboBx.Enab led = true;
fNameTxtBx.Enab led = true;
lNameTxtBx.Enab led = true;
surgeonNameCboB x.Enabled = false;
}
else
{
titleCboBx.Enab led = false;
fNameTxtBx.Enab led = false;
lNameTxtBx.Enab led = false;
surgeonNameCboB x.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. 3 1611
Have you set the AutoPostBack property of the CheckBox to true?
Otherwise it won't post back on checking it.
"Assimalyst " <c_******@hotma il.com> wrote in message
news:11******** *************@z 14g2000cwz.goog legroups.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.addNewSurg eonChkBx.Checke dChanged += new System.EventHan dler(this.addNe wSurgeonChkBx_C heckedChanged);
And the code called by this is:
private void addNewSurgeonCh kBx_CheckedChan ged(object sender, System.EventArg s e) { if (addNewSurgeonC hkBx.Checked == true) { titleCboBx.Enab led = true; fNameTxtBx.Enab led = true; lNameTxtBx.Enab led = true; surgeonNameCboB x.Enabled = false; } else { titleCboBx.Enab led = false; fNameTxtBx.Enab led = false; lNameTxtBx.Enab led = false; surgeonNameCboB x.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.
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.Enab led = !titleCboBx.Ena bled
fNameTxtBx.Enab led = !fNameTxtBx.Ena bled
Regards
Jignesh Desai - MVP
Blogs @ http://dotnetjini.jigneshdesai.com/Blogs/default.aspx
..NET Training Programs : http://dotnetjini.jigneshdesai.com/Training.aspx
"Assimalyst " <c_******@hotma il.com> wrote in message news:11******** *************@z 14g2000cwz.goog legroups.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.addNewSurg eonChkBx.Checke dChanged += new System.EventHan dler(this.addNe wSurgeonChkBx_C heckedChanged); And the code called by this is: private void addNewSurgeonCh kBx_CheckedChan ged(object sender, System.EventArg s e) { if (addNewSurgeonC hkBx.Checked == true) { titleCboBx.Enab led = true; fNameTxtBx.Enab led = true; lNameTxtBx.Enab led = true; surgeonNameCboB x.Enabled = false; } else { titleCboBx.Enab led = false; fNameTxtBx.Enab led = false; lNameTxtBx.Enab led = false; surgeonNameCboB x.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.
Thankyou both, problem solved. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 the span tag
in the case of a checkbox or a radiobutton. Effectively,
these controls are not disabled in netscape.
|
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 lot of Forecast and
Actual dates that can be entered, and next to each one an 'NA' checkbox
that I want to disable/grey-out both dates (and the JavaScript calendar
if possible). It also only has to work on Internet Explorer 6, as it
is for...
|
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 step you're on. This all works fine, but I ran into some
trouble when I started creating controls dynamically in my code-behind
file.
Each panel contains a table which is filled with various radio buttons,
text fields and the such which are...
|
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 hide the table.
Initially this CheckBox is not checked, so the table and all web control it
contains
is not rendered to a client. The table contains several TextBox controls and
each TextBox has a pair of RequiredFieldValidator and...
|
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 back sometimes all outlining is shown and
sometimes are not shown. I have no idea what is going wrong.
What also is weird is that when I open the form from my main application I
can resize the form, even though it is locked, and that when I cut...
| |
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?
|
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 the check box of all records were then
enabled, and user can click on check box.
This is how it should work:
When you enter a new record and click an option box (for example 1),
then the check box only for that record should be enabled. If the
|
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 the web service, with a web reference to those datasets via exposed s on the web service.
The client app has a series of windows forms designed to manage particular types of data. For example, there's a manage users form. On each of these...
|
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 been clicked, thann the fields remain disabled.
Could you please help me to write the VBA-code for this procedure?
Thank you!!
Alla
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |