Setting focus from Code Behind

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

Scott Mitchell [MVP]

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top