Enable/Disable of texbox
-
I need to know if my code is right to enable or disable any object in C#.net I use if condition.. is there other way to do it? :(( private void optBCLA01001_SelectedIndexChanged(object sender, System.EventArgs e) { if(optBCLA01001.SelectedIndex == 0) { optBCLA01006.Enabled = true; } }
-
I need to know if my code is right to enable or disable any object in C#.net I use if condition.. is there other way to do it? :(( private void optBCLA01001_SelectedIndexChanged(object sender, System.EventArgs e) { if(optBCLA01001.SelectedIndex == 0) { optBCLA01006.Enabled = true; } }
Kind of...It all depends on what a 'optBCLA01006' is. A button?...Checkbox?... For just about all of the usual form controls like buttons and checkboxes and radio buttons, textboxes, ... this is true. BTW: Those variable names are HORRIBLE because they are not descriptive of anything they represent. RageInTheMachine9532 "...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome
-
I need to know if my code is right to enable or disable any object in C#.net I use if condition.. is there other way to do it? :(( private void optBCLA01001_SelectedIndexChanged(object sender, System.EventArgs e) { if(optBCLA01001.SelectedIndex == 0) { optBCLA01006.Enabled = true; } }
By default all controls that you are going to place have a Enable property that will allow user to interact with. I think your aim is if the optionbutton is cliecked you ned to enable some control(eg: textbox or label). am i right ? if so. follow like this if(radiobutton1.checked) textboxme.Enabled=false; else textboxme.Enabled=true; here if you click on your radio button it will disable the textbox and if you unchecked it will show the enable the textbox. And on design time you have to deside what is the startup state of your control. Sreejith S S Nair
-
By default all controls that you are going to place have a Enable property that will allow user to interact with. I think your aim is if the optionbutton is cliecked you ned to enable some control(eg: textbox or label). am i right ? if so. follow like this if(radiobutton1.checked) textboxme.Enabled=false; else textboxme.Enabled=true; here if you click on your radio button it will disable the textbox and if you unchecked it will show the enable the textbox. And on design time you have to deside what is the startup state of your control. Sreejith S S Nair
Thanks... you understand me very well... But could we be more specific: I am using RadioButtonList & textbox. My code is this: private void RadioButtonList1_SelectedIndexChanged(object sender, System.EventArgs e) { if (RadioButtonList1.SelectedIndex ==0) { RadioButtonList2.Enabled=true ; textbox1.Enabled = true; } else { RadioButtonList2.Enabled=false ; textbox1.Enabled = false; } } I am using ASP.NET Web Application, Visual C# Project. The lunching of Internet Explorer is successful without error in build solution and start. My only problem is my code don't do anything. My code will not enable or disable any RadioButtonList or textbox. By the way my default settings of properties in "RadioButtonList2" in my code is disable and I want my code to enable it once the selectedindex is equal to 0 which is the first option of the user. Thanks and more power to you and to this website!!! chiao!!! :)
-
Thanks... you understand me very well... But could we be more specific: I am using RadioButtonList & textbox. My code is this: private void RadioButtonList1_SelectedIndexChanged(object sender, System.EventArgs e) { if (RadioButtonList1.SelectedIndex ==0) { RadioButtonList2.Enabled=true ; textbox1.Enabled = true; } else { RadioButtonList2.Enabled=false ; textbox1.Enabled = false; } } I am using ASP.NET Web Application, Visual C# Project. The lunching of Internet Explorer is successful without error in build solution and start. My only problem is my code don't do anything. My code will not enable or disable any RadioButtonList or textbox. By the way my default settings of properties in "RadioButtonList2" in my code is disable and I want my code to enable it once the selectedindex is equal to 0 which is the first option of the user. Thanks and more power to you and to this website!!! chiao!!! :)
sorry for this much time.cause i am not feeled well for last two days. ok. now i got your problem. change the AutoPostback property of your first radiolist box control into true.by default it is false. And then try the above mentioned code. have a nice day:-O Sreejith S S Nair
-
sorry for this much time.cause i am not feeled well for last two days. ok. now i got your problem. change the AutoPostback property of your first radiolist box control into true.by default it is false. And then try the above mentioned code. have a nice day:-O Sreejith S S Nair
Good Day!!! Wonderful.... It works!!! The textbox will enable/disable as I expected!Thank you very much for helping... (Running State)But I jst want to ask if the AutoPostBack will result to refresh effect? I mean each time I change my option to the RadioButtonList the whole web application will download again and will display the new changes made by the user. One more thing!!! How about the coding of CheckBoxList with 4 to 5 choices with corresponding textbox that will also enable each textbox if the choices are being checked. Here is my coding but it wont work as I expected: private void checkboxlist1_SelectedIndexChanged(object sender, System.EventArgs e) { if(checkboxlist1.SelectedIndex == 0) { textbox1.Enabled = true; } if(checkboxlist1.SelectedIndex == 1) { textbox2.Enabled = true; } if(checkboxlist1.SelectedIndex == 2) { textbox3.Enabled = true; } if(checkboxlist1.SelectedIndex == 3) { textbox4.Enabled = true; } } If I checked the first choice it will enable the textbox1 ang when I checked also the second choice the textbox2 will not enable, so on and so on to the other choices. The program will allow me to checked all the choices but will not enable all the corresponding texbox of each choices. Hope you could help me figure out whats wrong with my program.... Thanks and God Bless!!! :-D :doh:
-
Good Day!!! Wonderful.... It works!!! The textbox will enable/disable as I expected!Thank you very much for helping... (Running State)But I jst want to ask if the AutoPostBack will result to refresh effect? I mean each time I change my option to the RadioButtonList the whole web application will download again and will display the new changes made by the user. One more thing!!! How about the coding of CheckBoxList with 4 to 5 choices with corresponding textbox that will also enable each textbox if the choices are being checked. Here is my coding but it wont work as I expected: private void checkboxlist1_SelectedIndexChanged(object sender, System.EventArgs e) { if(checkboxlist1.SelectedIndex == 0) { textbox1.Enabled = true; } if(checkboxlist1.SelectedIndex == 1) { textbox2.Enabled = true; } if(checkboxlist1.SelectedIndex == 2) { textbox3.Enabled = true; } if(checkboxlist1.SelectedIndex == 3) { textbox4.Enabled = true; } } If I checked the first choice it will enable the textbox1 ang when I checked also the second choice the textbox2 will not enable, so on and so on to the other choices. The program will allow me to checked all the choices but will not enable all the corresponding texbox of each choices. Hope you could help me figure out whats wrong with my program.... Thanks and God Bless!!! :-D :doh:
Sure it will work.Write down your code on valuechange event. and try your all requirement. if you feel any uncomfortable please let me know that.:-O Sreejith S S Nair
-
Good Day!!! Wonderful.... It works!!! The textbox will enable/disable as I expected!Thank you very much for helping... (Running State)But I jst want to ask if the AutoPostBack will result to refresh effect? I mean each time I change my option to the RadioButtonList the whole web application will download again and will display the new changes made by the user. One more thing!!! How about the coding of CheckBoxList with 4 to 5 choices with corresponding textbox that will also enable each textbox if the choices are being checked. Here is my coding but it wont work as I expected: private void checkboxlist1_SelectedIndexChanged(object sender, System.EventArgs e) { if(checkboxlist1.SelectedIndex == 0) { textbox1.Enabled = true; } if(checkboxlist1.SelectedIndex == 1) { textbox2.Enabled = true; } if(checkboxlist1.SelectedIndex == 2) { textbox3.Enabled = true; } if(checkboxlist1.SelectedIndex == 3) { textbox4.Enabled = true; } } If I checked the first choice it will enable the textbox1 ang when I checked also the second choice the textbox2 will not enable, so on and so on to the other choices. The program will allow me to checked all the choices but will not enable all the corresponding texbox of each choices. Hope you could help me figure out whats wrong with my program.... Thanks and God Bless!!! :-D :doh:
don't think like this. if you got a little idea that HOW ? you have to develop the remaining. dear please use little logic and refer MSDN. This forum is for help only not for coding support.ok:-O try this if(CheckBoxList1.SelectedItem.Value.ToString()=="c1") TextBox1.Enabled=false; else TextBox1.Enabled=true; if(CheckBoxList1.SelectedItem.Value.ToString()=="c2") TextBox2.Enabled=false; else TextBox2.Enabled=true; if(CheckBoxList1.SelectedItem.Value.ToString()=="c3") TextBox3.Enabled=false; else TextBox3.Enabled=true; if(CheckBoxList1.SelectedItem.Value.ToString()=="c4") TextBox4.Enabled=false; else TextBox4.Enabled=true; if(CheckBoxList1.SelectedItem.Value.ToString()=="c5") TextBox5.Enabled=false; else TextBox5.Enabled=true; if(CheckBoxList1.SelectedItem.Value.ToString()=="c6") TextBox6.Enabled=false; else TextBox6.Enabled=true; Sreejith S S Nair