Home All Groups Group Topic Archive Search About

Asp.Net AutoPostback and control focus

Author
21 Jun 2006 1:43 PM
robin9876
In Asp.Net v1.1 web form I have a number of controls which have the
autopostback enabled. Is it possible after the autopostback has run
that the control that caused the autopostback to get the focus?

Author
23 Jun 2006 12:32 AM
Nathan Sokalski
I am not sure if there is a built-in way to do that, but you could generate
JavaScript that runs right away (not a function) that calls the focus()
method of the appropriate control. To do this, try using the following:


TextBox2.Page.RegisterClientScriptBlock("refocus", "<script
type=""text/javascript"">" & TextBox2.ClientID & ".focus();</script>")


I have not tested this code, but I would expect that it would work. Good
Luck!
--
Nathan Sokalski
njsokal***@hotmail.com
http://www.nathansokalski.com/

<robin9***@hotmail.com> wrote in message
Show quoteHide quote
news:1150897394.254204.63660@i40g2000cwc.googlegroups.com...
> In Asp.Net v1.1 web form I have a number of controls which have the
> autopostback enabled. Is it possible after the autopostback has run
> that the control that caused the autopostback to get the focus?
>