Focusing and Selecting the Text in ASP.NET TextBox Controls

  • Thread starter Thread starter 4GuysFromRolla.com
  • Start date Start date
4

4GuysFromRolla.com

Guest
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 <form> element, elements, elements, <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 focus, which gives keyboard focus to the corresponding element. The 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 select, which is available for <input> and <textarea> elements and selects the contents of the textbox.

This article shows how to call an HTML elements focus and 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!
Read More >

View the full article
 
Back
Top