Focusing and Selecting the Text in ASP.NET TextBox Controls

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
When a browser displays the HTML sent from a web server it parses the received markup into a Document Object Model, or DOM, which models the markup as a hierarchical structure.
Each element in the markup - the
Code:
<form>
element,
Code:
elements,
Code:
elements,
Code:
<input>
elements, and so on - are represented as a node in the DOM and can be programmatically accessed from client-side script. Whats more, the nodes that make up the DOM
have functions that can be called to perform certain behaviors; what functions are available depend on what type of element the node represents.

One function common to most all node types is
Code:
focus
, which gives keyboard focus to the corresponding element. The
Code:
focus
function is commonly
used in data entry forms, search pages, and login screens to put the users keyboard cursor in a particular textbox when the web page loads so that the user can start
typing in his search query or username without having to first click the textbox with his mouse. Another useful function is
Code:
select
, which is available for
Code:
<input>
and
Code:
<textarea>
elements and selects the contents of the textbox.

This article shows how to call an HTML elements
Code:
focus
and
Code:
select
functions. Well look at calling these functions directly from client-side
script as well as how to call these functions from server-side code. Read on to learn more!

http://www.4guysfromrolla.com/articles/021611-1.aspx" class="readmore Read More >

View the full article
 
Back
Top