WebControl.TabIndex 속성

정의

웹 서버 컨트롤의 탭 인덱스를 가져오거나 설정합니다.

public:
 virtual property short TabIndex { short get(); void set(short value); };
public virtual short TabIndex { get; set; }
member this.TabIndex : int16 with get, set
Public Overridable Property TabIndex As Short

속성 값

Int16

웹 서버 컨트롤의 탭 인덱스입니다. 기본값은 0로, 이 속성이 설정되어 있지 않음을 나타냅니다.

예외

지정된 탭 인덱스가 -32768와 32767 범위에 없는 경우

예제

다음 예제를 사용 하는 방법을 TabIndex 의 속성을 WebControl 페이지에 있는 컨트롤의 탭 순서를 설정 합니다.

참고

다음 코드 샘플 단일 파일 코드 모델을 사용 하 고 코드 숨김 파일에 직접 복사 하는 경우 제대로 작동 하지 않을 수 있습니다. 이 코드 샘플.aspx 확장명이 있는 빈 텍스트 파일에 복사 해야 합니다. Web Forms 코드 모델에 대 한 자세한 내용은 참조 하세요. ASP.NET Web Forms 페이지 코드 모델합니다.

중요

이 예제에는 사용자 입력을 허용하는 텍스트 상자가 있으므로 보안상 위험할 수 있습니다. 기본적으로 ASP.NET 웹 페이지는 사용자 입력 내용에 스크립트 또는 HTML 요소가 포함되어 있지 않은지 확인합니다. 자세한 내용은 Script Exploits Overview를 참조하세요.

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
 
    void SubmitBtn1_Click(Object sender, EventArgs e)
    {
        SubmitBtn1.TabIndex = 0;
        TextBox1.TabIndex = (short)((TextBox1.Text=="") ? 0 : 
            System.Int32.Parse(TextBox1.Text));
        TextBox2.TabIndex = (short)((TextBox2.Text=="") ? 0 : 
            System.Int32.Parse(TextBox2.Text));
        TextBox3.TabIndex = (short)((TextBox3.Text=="") ? 0 : 
            System.Int32.Parse(TextBox3.Text));
    }

</script>
 

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head2" runat="server">
    <title>Enabled Property Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

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

    <p>
        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.
    </p>
 
    <p><asp:Button id="SubmitBtn1" OnClick="SubmitBtn1_Click" 
            Text="Submit" runat="server"/>
    </p>

    <p><asp:TextBox id="TextBox1" BackColor="Pink" 
            runat="server"/>
    </p>
    <p><asp:TextBox id="TextBox2" BackColor="LightBlue" 
            runat="server"/>
    </p>
    <p><asp:TextBox id="TextBox3" BackColor="LightGreen" 
            runat="server"/>
    </p>  
     
    </div>
    </form>
</body>
</html>
<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

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

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head2" runat="server">
    <title>Enabled Property Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

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

    <p>
        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.
    </p>
 
    <asp:Button id="SubmitBtn1" OnClick="SubmitBtn1_Click" 
        Text="Submit" runat="server"/>
    <p>
        <asp:TextBox id="TextBox1" BackColor="Pink" 
            runat="server"/>
    </p>
    <p>
        <asp:TextBox id="TextBox2" BackColor="LightBlue" 
            runat="server"/>
    </p>
    <p>
        <asp:TextBox id="TextBox3" BackColor="LightGreen" 
            runat="server"/>
    </p>  

    </div>
    </form>
</body>
</html>

설명

사용 된 TabIndex 속성을 지정 하거나 Web Forms 페이지의 웹 서버 컨트롤의 탭 인덱스를 확인 합니다. 누를 때 합니다 Tab 키를 웹 서버 컨트롤이 포커스를 받는 순서에 의해 결정 됩니다는 TabIndex 각 컨트롤의 속성입니다. 처음에 페이지를 로드 하는 경우 받는 첫 번째 항목 포커스를 Tab 키를 누르면 주소 표시줄은입니다. 값을 기준으로 오름차순으로 Web Forms 페이지의 컨트롤에 탭은 다음으로 TabIndex 가장 작은 양수, 0이 아닌 값으로 시작 하는 각 컨트롤의 속성입니다. 여러 컨트롤 같은 탭 인덱스를 공유 하는 경우 컨트롤이 Web Forms 페이지에 선언 된 순서에 포커스를 받습니다. 마지막으로, 0의 탭 인덱스를 포함 하는 컨트롤 탭이 지정 됩니다 선언 된 순서입니다.

참고

0이 아닌 탭 인덱스를 가진 컨트롤만 렌더링 합니다는 tabindex 특성입니다.

탭 순서에서 설정 하 여 웹 서버 컨트롤을 제거할 수 있습니다는 TabIndex 속성을 음수 값입니다.

참고

이 속성은 Internet Explorer 4 에서만에서 이상 지원 합니다.

적용 대상

추가 정보