473,405 Members | 2,279 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Setting focus from Code Behind

Vi
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.
Nov 18 '05 #1
2 2272
Vi wrote:
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
mi******@4guysfromrolla.com
http://www.4GuysFromRolla.com

* When you think ASP.NET, think 4GuysFromRolla.com!
Nov 18 '05 #2
Check out this code snippet,
http://www.extremeexperts.com/Net/Co...rPostback.aspx

--
Saravana
http://dotnetjunkies.com/WebLog/saravana/
www.ExtremeExperts.com
"Vi" <Vi@discussions.microsoft.com> wrote in message
news:E8**********************************@microsof t.com...
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.

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Todd | last post by:
Does anyone know how to set the focus to a control programatically in my code for an asp.net app? -- Thanks in advance, Todd
2
by: Mystery Man | last post by:
We have an MDI application that is not setting always setting focus to the newly corrected MDI. It is creating the form and it is the topmost but it does not have focus. The code we are using to...
4
by: Kent P. Iler | last post by:
Hi, I am showing/hiding a variety of panels that have different text boxes via code-behind functions. Depending on the condition, I would like to have the focus be set on a specific text box. ...
1
by: Frank Yamrick | last post by:
I am trying to program an application that requires a large number of screnes that are very similar in the respect that all the bottons and labels interact with each other with the same...
1
by: reidarT | last post by:
I have a webform and found some code where I understand some of it, but not all The code is as follows public static void SetFocus(Control control) { StringBuilder sb = new StringBuilder(); ...
2
by: mfleet1973 | last post by:
Hello (again), Within my datagrid I add a control to the datagridtextboxcolumn when the underlying textbox receives focus as follows: Combobox1.Size = New...
2
by: kloppie | last post by:
Hi there, im working on a page which causes me problems - the page contains of a couple of controls where the user can choose some options for a Report. When the user then clicks a button...
4
by: Jason | last post by:
Hi, Here's the scenario: I have a web application that has window A and window B. A user has both window A and B open - window A is in the foreground and window B is behind it. If the...
11
by: slinky | last post by:
I'm trying to simply set the focus of "txtUserName" upon opening this login form. I put in some Javascript but it is not working. Any ideas? Thanks! <%@ Page Language="vb"...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.