Aracılığıyla paylaş


BulletedList.FirstBulletNumber Özellik

Tanım

Sıralı BulletedList denetimdeki liste öğelerinin numaralandırmasını başlatan değeri alır veya ayarlar.

public:
 virtual property int FirstBulletNumber { int get(); void set(int value); };
public virtual int FirstBulletNumber { get; set; }
member this.FirstBulletNumber : int with get, set
Public Overridable Property FirstBulletNumber As Integer

Özellik Değeri

Sıralı BulletedList denetimdeki liste öğelerinin numaralandırmasını başlatan değer. Varsayılan değer: 1.

Örnekler

Aşağıdaki kod örneği, bir BulletedList denetimin nasıl oluşturulacağını ve denetimdeki FirstBulletNumber liste öğelerinin BulletedList numaralandırmasını başlatan değeri belirtmek için özelliğinin nasıl ayarlandığını gösterir. Liste öğelerinin numaralandırmasını başlatan değer, kullanıcının metin kutusuna girdiği değere göre değişir.

Ö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">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
  <title>First Bullet Number Example</title>
  <script runat="server">

    void Index_Changed(object sender, System.EventArgs e)
    {
        
      // Set the starting number for the bulleted list.
        ItemsBulletedList.FirstBulletNumber = Convert.ToInt32(StartValue.Text);
        switch (BulletStylesListBox.SelectedIndex) 
      {
            case 0:
                ItemsBulletedList.BulletStyle = BulletStyle.Numbered;
                break;
            case 1:
                ItemsBulletedList.BulletStyle = BulletStyle.LowerAlpha;
                break;
            case 2:
                ItemsBulletedList.BulletStyle = BulletStyle.UpperAlpha;
                break;
            case 3:
                ItemsBulletedList.BulletStyle = BulletStyle.LowerRoman;
                break;
            case 4:
                ItemsBulletedList.BulletStyle = BulletStyle.UpperRoman;
                break;
            default:
                throw new Exception("You did not select a valid bullet style");
                break;
        }
    }

  </script>

</head>
<body>

  <h3>First Bullet Number Example</h3>

  <form id="form1" runat="server">
                    
    <asp:BulletedList id="ItemsBulletedList"             
      BulletStyle="Disc" 
      DisplayMode="Text"
      runat="server">    
        <asp:ListItem Value="http://www.cohowinery.com">Coho Winery</asp:ListItem>
        <asp:ListItem Value="http://www.contoso.com">Contoso, Ltd.</asp:ListItem>
        <asp:ListItem Value="http://www.tailspintoys.com">Tailspin Toys</asp:ListItem>
    </asp:BulletedList>    
              
    <hr />
        
    <h4>Enter the first number to start the list</h4>        
        
    <asp:TextBox id="StartValue" 
      Text="1"
      runat="server">
    </asp:TextBox><br />    
            
    <asp:RangeValidator id="Range1" 
      ControlToValidate="StartValue"
      MinimumValue="1"
      MaximumValue="32000"
      Type="Integer"
      ErrorMessage="Please enter a number greater than zero and less than 32,000."
      runat="server">
    </asp:RangeValidator><br />            
        
    <h4>Select a bullet type:</h4>
    <asp:ListBox id="BulletStylesListBox" 
      SelectionMode="Single"
      Rows="1"
      AutoPostBack="True"
      OnSelectedIndexChanged="Index_Changed"
      CausesValidation="true"
      runat="server" >        
        <asp:ListItem Value="Numbered">Numbered</asp:ListItem>
        <asp:ListItem Value="LowerAlpha">LowerAlpha</asp:ListItem>
        <asp:ListItem Value="UpperAlpha">UpperAlpha</asp:ListItem>
        <asp:ListItem Value="LowerRoman">LowerRoman</asp:ListItem>
        <asp:ListItem Value="UpperRoman">UpperRoman</asp:ListItem>       
    </asp:ListBox><br />

    <hr />
  </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">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
  <title>First Bullet Number Example</title>
  <script runat="server">

    Sub Index_Changed(ByVal sender As Object, ByVal e As System.EventArgs)
      
      ' Set the starting number for the bulleted list.
      ItemsBulletedList.FirstBulletNumber = StartValue.Text
      Select Case (BulletStylesListBox.SelectedIndex)
        Case 0
          ItemsBulletedList.BulletStyle = BulletStyle.Numbered
        Case 1
          ItemsBulletedList.BulletStyle = BulletStyle.LowerAlpha
        Case 2
          ItemsBulletedList.BulletStyle = BulletStyle.UpperAlpha
        Case 3
          ItemsBulletedList.BulletStyle = BulletStyle.LowerRoman
        Case 4
          ItemsBulletedList.BulletStyle = BulletStyle.UpperRoman
        Case Else
          Throw New Exception("You did not select a valid bullet style")
      End Select
    End Sub

  </script>

</head>
<body>

  <h3>First Bullet Number Example</h3>

  <form id="form1" runat="server">
                    
    <asp:BulletedList id="ItemsBulletedList"             
      BulletStyle="Disc" 
      DisplayMode="Text"
      runat="server">    
        <asp:ListItem Value="http://www.cohowinery.com">Coho Winery</asp:ListItem>
        <asp:ListItem Value="http://www.contoso.com">Contoso, Ltd.</asp:ListItem>
        <asp:ListItem Value="http://www.tailspintoys.com">Tailspin Toys</asp:ListItem>
    </asp:BulletedList>    
              
    <hr />
        
    <h4>Enter the first number to start the list</h4>        
        
    <asp:TextBox id="StartValue" 
      Text="1"
      runat="server">
    </asp:TextBox><br />    
            
    <asp:RangeValidator id="Range1" 
      ControlToValidate="StartValue"
      MinimumValue="1"
      MaximumValue="32000"
      Type="Integer"
      ErrorMessage="Please enter a number greater than zero and less than 32,000."
      runat="server" >
    </asp:RangeValidator><br />            
        
    <h4>Select a bullet type:</h4>
    <asp:ListBox id="BulletStylesListBox" 
      SelectionMode="Single"
      Rows="1"
      AutoPostBack="True"
      OnSelectedIndexChanged="Index_Changed"
      CausesValidation="true"
      runat="server" >        
        <asp:ListItem Value="Numbered">Numbered</asp:ListItem>
        <asp:ListItem Value="LowerAlpha">LowerAlpha</asp:ListItem>
        <asp:ListItem Value="UpperAlpha">UpperAlpha</asp:ListItem>
        <asp:ListItem Value="LowerRoman">LowerRoman</asp:ListItem>
        <asp:ListItem Value="UpperRoman">UpperRoman</asp:ListItem>
    </asp:ListBox><br />

    <hr />
  </form>

</body>
</html>

Açıklamalar

Sıralı BulletedList denetimde FirstBulletNumber liste öğelerinin numaralandırmasını başlatan değeri belirtmek için özelliğini kullanın. Özelliğin , , CircleSquareveya CustomImage değerlerine ayarlanmış Discolması durumunda BulletStyle özelliğe atanan FirstBulletNumber değer yoksayılır. özelliğinin FirstBulletNumber değeri bir tamsayı olsa da, her zaman bir madde işaretinin sayı olarak işlenmesine neden olmaz. Örneğin, özelliğini olarak ve FirstBulletNumber özelliğini 4 değerine LowerAlphaayarlarsanızBulletStyle, ilk madde işareti numarası küçük harf d olarak işlenir.

Bu özelliğin değeri görünüm durumunda depolanır.

Şunlara uygulanır

Ayrıca bkz.