WebControl.TabIndex Özellik

Tanım

Web sunucusu denetiminin sekme dizinini alır veya ayarlar.

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

Özellik Değeri

Web sunucusu denetiminin sekme dizini. Varsayılan değer, 0bu özelliğin ayarlanmadığını gösteren değeridir.

Özel durumlar

Belirtilen sekme dizini -32768 ile 32767 arasında değil.

Örnekler

Aşağıdaki örnekte, sayfadaki denetimlerin TabIndex sekme sırasını ayarlamak için özelliğinin WebControl nasıl kullanılacağı gösterilmektedir.

Not

Aşağıdaki kod örneği tek dosyalı kod modelini kullanır ve doğrudan arka planda kod dosyasına kopyalandığında düzgün çalışmayabilir. Bu kod örneği, .aspx uzantısına sahip boş bir metin dosyasına kopyalanmalıdır. Web Forms kod modeli hakkında daha fazla bilgi için bkz. Sayfa Kodu Modeli ASP.NET Web Forms.

Önemli

Bu örnekte, olası bir güvenlik tehdidi olan kullanıcı girişini kabul eden bir metin kutusu vardır. Varsayılan olarak, ASP.NET Web sayfaları kullanıcı girişinin betik veya HTML öğeleri içermediğini doğrular. Daha fazla bilgi için bkz. Betik Açıklarına Genel Bakış.

<%@ 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>

Açıklamalar

TabIndex Web Forms sayfasında bir Web sunucusu denetiminin sekme dizinini belirtmek veya belirlemek için özelliğini kullanın. Tuşa Tab bastığınızda, Web sunucusu denetimlerinin odağı alma sırası her denetimin TabIndex özelliği tarafından belirlenir. Sayfa başlangıçta yüklendiğinde, tuşa basıldığında Tab odağı alan ilk öğe adres çubuğudur. Ardından, Web Forms sayfasındaki denetimler, en küçük pozitif, sıfır olmayan değerden başlayarak her denetimin özelliğinin TabIndex değerine göre artan düzende olarak sekmeli olarak gösterilir. Birden çok denetim aynı sekme dizinini paylaşıyorsa, denetimler odağı Web Forms sayfasında bildirdikleri sırayla alır. Son olarak, sıfır sekme dizinine sahip denetimler, bildirdikleri sırayla sekmeli olarak gösterilir.

Not

Özniteliği yalnızca sıfır olmayan sekme dizinine sahip denetimler tabindex işler.

Özelliği negatif bir değere ayarlayarak bir Web Sunucusu denetimini sekme sırasına TabIndex göre kaldırabilirsiniz.

Not

Bu özellik yalnızca Internet Explorer 4 ve sonraki sürümlerde desteklenir.

Şunlara uygulanır

Ayrıca bkz.