Home All Groups Group Topic Archive Search About

Does text box have "lost focus" event?

Author
24 Mar 2010 8:39 PM
aspfun via DotNetMonster.com
Does text box have "lost focus" event?

For example, there are two text boxes, txtAccountNumber and txtName. Once
user inputs account number into txtAccountNumber and move to txtName before
inputing name,  I want to fire a sub to verify this account number.

Is it possible?

--
Message posted via http://www.dotnetmonster.com

Author
25 Mar 2010 5:30 PM
Nathan Sokalski
The JavaScript event that occurs when a user leaves a TextBox is onblur. If
you want to do something server-side when the user leaves the Textbox, there
are several choices. One would be to set the AutoPostBack property to True.
However, note that setting the AutoPostBack property uses the onchange
JavaScript event rather than onblur, which means that the postback will only
occur if the TextBox's value has changed, so the server-side TextChanged
event will be triggered as well. If you want the postback to occur when the
user leaves the TextBox regardless of whether or not the value has changed,
your best choice is to either manually add the onblur JavaScript event
handler, or do this by writing a custom control that inherits TextBox. If
you plan on having a lot of TextBoxes that postback when the user leaves
them, I would suggest the latter. Hopefully this helps.
--
Nathan Sokalski
njsokal***@hotmail.com
http://www.nathansokalski.com/

"aspfun via DotNetMonster.com" <u53138@uwe> wrote in message
news:a580c5b81287d@uwe...
Show quoteHide quote
> Does text box have "lost focus" event?
>
> For example, there are two text boxes, txtAccountNumber and txtName. Once
> user inputs account number into txtAccountNumber and move to txtName
> before
> inputing name,  I want to fire a sub to verify this account number.
>
> Is it possible?
>
> --
> Message posted via http://www.dotnetmonster.com
>