Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - Enabling/Disabling Form controls with checkbox click.

 
Thread Tools Search this Thread
Old 08-09-2005, 10:46 AM   #1
Default 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.



Assimalyst
  Reply With Quote
Old 08-09-2005, 11:35 AM   #2
Jignesh Desai
 
Posts: n/a
Default Re: Enabling/Disabling Form controls with checkbox click.
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" <> wrote in message news: 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.
>



Jignesh Desai
  Reply With Quote
Old 08-09-2005, 11:35 AM   #3
Grant Merwitz
 
Posts: n/a
Default Re: Enabling/Disabling Form controls with checkbox click.
Have you set the AutoPostBack property of the CheckBox to true?
Otherwise it won't post back on checking it.


"Assimalyst" <> wrote in message
news: 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.
>





Grant Merwitz
  Reply With Quote
Old 08-09-2005, 11:51 AM   #4
Assimalyst
 
Posts: n/a
Default Re: Enabling/Disabling Form controls with checkbox click.
Thankyou both, problem solved.



Assimalyst
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to activate Remote Assistance with XP using Windows Live Messenger Oziisr General Help Related Topics 0 02-01-2008 04:45 PM
How to make your wonderful photo and video slideshow on DVD kricww@gmail.com DVD Video 0 04-20-2006 07:26 AM
Converting PAL DVDs to NTSC DVDs. Wild Coyote DVD Video 14 10-27-2004 09:58 PM
winsock.dll J A+ Certification 7 07-20-2004 01:01 AM
Latest Tech Fiasco... Ghost A+ Certification 30 01-09-2004 12:15 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46