This documentation is archived and is not being maintained.

WebControl.TabIndex Property

Gets or sets the tab index of the Web server control.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

Public Overridable Property TabIndex As Short
<asp:WebControl TabIndex="Int16" />

Property Value

Type: System.Int16
The tab index of the Web server control. The default is 0, which indicates that this property is not set.


The specified tab index is not between -32768 and 32767.

Use the TabIndex property to specify or determine the tab index of a Web server control on the Web Forms page. When you press the Tab key, the order in which the Web server controls receive focus is determined by the TabIndex property of each control. When a page is initially loaded, the first item that receives focus when the Tab key is pressed is the address bar. Next, the controls on the Web Forms page are tabbed to in ascending order, based on the value of the TabIndex property of each control, starting with the smallest positive, nonzero value. If multiple controls share the same tab index, the controls will receive focus in the order they are declared on the Web Forms page. Finally, controls that have a tab index of zero are tabbed to in the order they are declared.


Only controls with a nonzero tab index will render the tabindex attribute.

You can remove a Web Server control from the tab order by setting the TabIndex property to a negative value.


This property is supported only in Internet Explorer 4 and later.

The following example illustrates how to use the TabIndex property of the WebControl to set the tab order of controls on the page.


The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information on the Web Forms code model, see ASP.NET Web Page Code Model.

Security noteSecurity Note

This example has a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see Script Exploits Overview.

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 

<script runat="server">

    Sub SubmitBtn1_Click(sender As Object, e As EventArgs)
        SubmitBtn1.TabIndex = 0
        If TextBox1.Text = "" Then
            TextBox1.TabIndex = 0
            TextBox1.TabIndex = System.Int16.Parse(TextBox1.Text)
        End If
        If TextBox2.Text = "" Then
            TextBox2.TabIndex = 0
            TextBox2.TabIndex = System.Int16.Parse(TextBox2.Text)
        End If
        If TextBox3.Text = "" Then
            TextBox3.TabIndex = 0
            TextBox3.TabIndex = System.Int16.Parse(TextBox3.Text)
        End If
    End Sub


<html xmlns="" >
<head id="Head2" runat="server">
    <title>Enabled Property Example</title>
    <form id="form1" runat="server">

    <h3>TabIndex Property of a Web Control<br /></h3>

        Enter a number (1, 2, or 3) in each text box, <br /> 
        click the Submit button to set the TabIndexes, then <br /> 
        click on the page and tab through the page to verify.

    <asp:Button id="SubmitBtn1" OnClick="SubmitBtn1_Click" 
        Text="Submit" runat="server"/>
        <asp:TextBox id="TextBox1" BackColor="Pink" 
        <asp:TextBox id="TextBox2" BackColor="LightBlue" 
        <asp:TextBox id="TextBox3" BackColor="LightGreen" 


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.