Text Box events

  • Thread starter Thread starter jhcruz
  • Start date Start date
J

jhcruz

I'm trying to disable one text box when a user starts entering data in
a different text box. Is this even possible? If so can someone point
me towards a good example?

Thanks,

Jaime
 
Hi Jaime,

You can diable the first Textbox whenevr you type anything in the second
textbox by using this code:

Protected Sub TextBox2_TextChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles TextBox2.TextChanged
Me.TextBox1.Enabled = False
End Sub

Set the AutoPostback property of the second textBox to True and as soon as
the focus from the second textbox is out, the first textbox is disbaled.

Regards,
Manish
www.ComponentOne.com
 
You can diable the first Textbox whenevr you type anything in the second
textbox by using this code:

Protected Sub TextBox2_TextChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles TextBox2.TextChanged
Me.TextBox1.Enabled = False
End Sub

Set the AutoPostback property of the second textBox to True and as soon as
the focus from the second textbox is out, the first textbox is disbaled.


The above requires a totally unnecessary roundtrip to the server and back...

<asp:TextBox ID="TextBox1" runat="server" />
<asp:TextBox ID="TextBox2" runat="server" />

private void Page_Load(object sender, System.EventArgs e)
{
TextBox1.Attributes.Add("onkeypress", "document.getElementById('" +
TextBox2.ClientID + "').disabled=\"disabled\";");
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top