다음을 통해 공유


BulletedList.FirstBulletNumber 속성

정의

순서 있는 BulletedList 컨트롤의 목록 항목 번호 매기기를 시작할 값을 가져오거나 설정합니다.

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

속성 값

순서 있는 BulletedList 컨트롤의 목록 항목 번호 매기기를 시작할 값입니다. 기본값은 1입니다.

예제

다음 코드 예제에는 만드는 방법을 보여 줍니다는 BulletedList 제어 하 고 설정 합니다 FirstBulletNumber 속성의 목록 항목 번호 매기기를 시작 하는 값을 지정 하는 BulletedList 컨트롤입니다. 목록 항목 변경 내용의 번호 매기기를 시작 하는 값을 텍스트 상자에 사용자가 입력 하는 값을 기반으로 합니다.

중요

이 예제에는 사용자 입력을 허용하는 텍스트 상자가 있으므로 보안상 위험할 수 있습니다. 기본적으로 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">
<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>

설명

사용 된 FirstBulletNumber 순서 있는 목록 항목 번호 매기기를 시작 하는 값을 지정 하는 속성 BulletedList 컨트롤입니다. 에 할당 된 값을 FirstBulletNumber 경우 속성이 무시 됩니다는 BulletStyle 속성이로 설정 되어를 Disc, Square, Circle, 또는 CustomImage 값. 하지만 값은 FirstBulletNumber 속성은 정수, 숫자로 렌더링 글머리 기호가 항상 발생 하지 않습니다. 예를 들어, 설정 하는 경우는 FirstBulletNumber 속성을 4 설정 합니다 BulletStyle 속성 값을 LowerAlpha, 소문자 d로 렌더링 됩니다. 첫 번째 글머리 기호 수입니다.

이 속성의 값은 뷰 상태에 저장 됩니다.

적용 대상

추가 정보