Text Box events

Text Box events

am 14.01.2008 22:10:22 von 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

RE: Text Box events

am 15.01.2008 06:35:00 von Manish

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


"jhcruz@jmaweb.biz" wrote:

> 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
>

Re: Text Box events

am 15.01.2008 09:05:30 von mark

"Manish" wrote in message
news:A6687B13-88A4-403E-BBD8-37EA92826B7A@microsoft.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...




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


--
Mark Rae
ASP.NET MVP
http://www.markrae.net