Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi I have a form that has multiple Textboxes TextBox1, Textbox2, TextBox3 etc. Is there a way to disable TextBox2, TextBox3 etc and when the user enters data into TextBox1 enable TextBox2, when data is entered into TextBox2 enable TextBox3 etc.

Thank you
Ajmiester
Posted

<br />
TextBox2.Enabled=false;<br />
TextBox3.Enabled=false;<br />
<br />
<br />
<br />
TextBox1.TextChanged += new EventHandler(TextBox1_TextChanged);<br />
<br />
void TextBox1_TextChanged(object sender, EventArgs e<br />
{<br />
    TextBox2.Enabled=true;<br />
}<br />
<br />
void TextBox2_TextChanged(object sender, EventArgs e)<br />
{<br />
    TextBox3.Enabled=true;<br />
}
 
Share this answer
 
javascript is better way to handle enable/disable the textbox in client side. you can use onkeyup/onfocus events of texbox.
 
Share this answer
 
Comments
MalikRizwan 29-Sep-10 0:20am    
why this answer is low rated? even i find it better than other answers? i have rated it 5 anyway
textbox1.text=false;
textbox2.text=false;

and write the code in textbox changed event.
 
Share this answer
 
Use JavaScript to Enabled and Disabled the Textbox ! As your textbox is the server side control, so first read the "ClientID" then get the id using document.GetElementByID(ClientID).
 
Share this answer
 
Comments
saini arun 29-Sep-10 3:43am    
Why only 1 vote for this answer?
Please specify if you need the complete code for this.
Abhijit Jana 29-Sep-10 4:57am    
I didn't understand what do you mean.
Hiren solanki 9-Nov-10 8:50am    
He is shouting because you got uni-vote for you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900