Tab Order, Focus, and Access Keys in ASP.NET Web Server Controls
To enhance the user experience of using controls in ASP.NET Web pages, you can specify the order in which users can tab through ASP.NET Web server controls, and you can specify which control on the page has the focus when the page is initially opened.
When pages are displayed in the browser, users can use a TAB key (TAB and SHIFT+TAB on Windows) to move the focus/selection from control to control on the page. In most browsers, by default, the tab order for controls is the order in which they appear in the page, beginning at the top left of the page and continuing to the bottom right of the page.
You can control the tab order for controls by setting their TabIndex property. When the controls are rendered, the TabIndex value is rendered into the attribute for the browser required to support tabbing. In Internet Explorer, for example, the TabIndex value is rendered as the tabindex attribute of an element on the page.
Tab order goes up sequentially, so that when a user moves from a control with a TabIndex property set to 3, the focus then goes to the control with the TabIndex value of 4 (or higher). In many browsers, including Internet Explorer, tab order includes controls that are located on the browser toolbar.
With some controls, pressing the TAB key can cause the control to perform a postback. For example, if you set a TextBox control'sproperty to true, moving from the text box that contains changed text causes the page to post.
When a page is rendered to the browser, the browser determines which control should have the focus. In most cases, the browser initially puts focus on the browser window itself or the first control on the page. This is true even after a postback, because the page is being re-created on the server and the browser considers it a new page. (An exception is after a postback caused by a TAB key, as explained earlier in the "Tab Order" section of this topic.)
If it is important to have the focus on a specific control in your application, you can set the focus on a control from server code. For details, see.
Not all controls can receive focus. You can set the focus on any of the following:
If a control is hidden, it cannot receive the focus. If you set focus on a control that cannot receive focus directly but that has child controls that can receive the focus, the first child control will receive focus. For example, if you set the focus on thecontrol, the first text box that is located inside the Login control will receive the focus.
In addition to supporting tab order in your ASP.NET Web pages, you can add support for access keys (also known as hot keys). An access key allows users to press the ALT key plus another key (for example, ALT+S) to jump to a specific control on the page without using the mouse.
For details, see.