Setting focus from Code Behind

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

Guest

Hi,
Is there a way to set the focus to a TextBox or a DropDownList from the code
behind? Simething you would do from the client side code wiht
myTextBox.focus() or myTextBox.select().

Thank you.
 
Vi said:
Is there a way to set the focus to a TextBox or a DropDownList from the code
behind? Simething you would do from the client side code wiht
myTextBox.focus() or myTextBox.select().

Yeah, you have to emit a bit of JavaScript. I discuss this and have
source code that shows precisely how to do this in the article:

Working with Client-Side Script
http://tinyurl.com/4qho3

There's also the free FirstFocus control from Andy Smith:
http://metabuilders.com/Tools/FirstFocus.aspx

Happy Programming!

--

Scott Mitchell
(e-mail address removed)
http://www.4GuysFromRolla.com

* When you think ASP.NET, think 4GuysFromRolla.com!
 
Back
Top