OnLeave event on a textbox?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi NG,

Can anyone tell me how to create a OnLeave event on a regular textbox in an
ASP.NET webform? The only events I have available are: TextChanged, Disposed,
Init, Load, Prerender and Unload..

Thanks!

regards,

M.L.
 
Hi,

I want to disable another textbox in the same form if the user has entered
anything into the first box. The OnLeave is needed to determine whether this
is true. Like so:

private void TextBox1_OnLeave()
{
if (TextBox1.Text.Length > 0)
TextBox2.Enabled = false;
}

How can this be implemented?

Thanks!
 
Hi,

Thanks very much for the solution, but in fact I would prefer to do it
server-side.. Is this not possible?
 
You can do it on client side with an onblur event. What do you want to do on
this event?

Eliyahu
 
<asp:textbox id=TextBox1 ...
onblur="document.getElementById('TextBox2').disabled=(this.value=='')" ...

<asp:textbox id=TextBox2 ...

No server-side code is required.

Eliyahu
 
If the user enters something, you will get a server-side TextChanged event.
Is not it good for you?

Eliyahu
 
No. This event happens on the client in the browser. The server is on the
othe rend of the wire - it has no idea that the user switched focus to a
different field.

You can trigger a postback to the server - but you would still need client
side code to trigger this. And then your page looks ugly because it keeps
flashing.
 
Back
Top