asp.net2.0 New Controls-bulletedlist

Source: Internet
Author: User
Tags lowercase xpath xsl
Asp.net| control BulletedList is a control that makes it easy for you to display bulleted and numbered formats (bulledted List) on a page. For ASP.net 1.x to dynamically display the bulledted list, either use the HTML <ol> or <ul> element constructs, or the "overkill" use repeater to display. The former is too inflexible, the latter is too overkill, perhaps Microsoft hears this kind of sound, so asp.net 2.0 finally got a bulletedlist come out. Although the control is not too much attention, but it can be seen that Microsoft really care about the "user needs." The main properties of the BulletedList control are BulletStyle, DisplayMode, items, and main Event click. l        BulletStyle: A bulleted number style value that corresponds to a System.Web.UI.WebControls.BulletStyle enumeration type value. It has the following 10 options:1.      Circle: Indicates that the bullet numbering style is set to "0" empty circle. 2.      Customimage: Indicates that the bullet numbering style is set to a custom picture, and its picture is specified by the Bulletimageurl property. 3.      Disc: Indicates that the bullet numbering style is set to "" in real circles. 4.      Loweralpha: Indicates that the bulleted numbering style is formatted as a lowercase letter. such as a, B, C, D, such as 26 lowercase English letters. 5.      Lowerroman: Indicates that the bullet numbering style is set to lowercase roman numeral format. such as I, II, III, IV, and other lowercase roman numerals. 6.      NotSet: Indicates that the bullet numbering style is not set. This is displayed as the default style in disc style. 7.      numbered: Indicates that the bullet numbering style is set to a number format. such as 1, 2, 3, 4 and other digital formats. 8.     Square: Indicates that the bulleted number style is the entity black box. 9.      Upperalpha: Indicates that the bulleted numbering style is formatted in uppercase letters. such as a, B, C, D, and so on 26 uppercase English letters. 10.  Upperroman: Indicates that the bullet numbering style is formatted as uppercase Roman numerals. Roman numerals in capitals such as I, II, III, IV, etc. l        DisplayMode: The name implies the display mode, Corresponds to the System.Web.UI.WebControls.BulletedListDisplayMode enumeration type value. It has the following three options:1.      text: Represents a list of items in plain text. 2.      HyperLink: Represents a list of items in a hyperlink form. Link text is the Text property of a specific item listitem, and the link target is the Value property of ListItem. 3.      LinkButton: Represents a list of items in the form of a server control LinkButton. Each ListItem item is then displayed as LinkButton, and the Click event is sent back to the server side for appropriate action. l        Items: This property corresponds to a collection of System.Web.UI.WebControls.ListItem objects. Each item in a bulleted numbered list corresponds to a ListItem object. The ListItem object has four primary properties:?        enabled: Whether the item is active. The default is true.?        Selected: The item is selected. The default is true.?        text: The display text for the item.?        Value: The values of the item. L        Click: This event is in LinkButton mode for the DisplayMode of the BulletedList control. and BulletedList when an item in the control is clicked. The index number (starting from 0) of the clicked item in all items list is passed back to the server side as a return parameter when triggered.   for a variety of bulletstyle, here only a screenshot for viewing, see the various bulletstyle in the actual appearance.   Similarly, here are three simple examples of three displaymode scenarios to better understand the various property methods and applications of BulletedList.   1. Text display mode:This pattern is the simplest and only provides a list of items to display. The expression code is: <asp:bulletedlist id= "BulletedList1" bulletstyle= "Circle" runat= "Server" > <asp:listitem >item #1 </asp:ListItem> <asp:listitem>item #2 </asp:ListItem> <asp:listitem T         ext= "Item #3" ></asp:ListItem> <asp:listitem text= "Item #4" value= "Item #4" ></asp:ListItem> </asp:BulletedList> of course, data binding can also be used to achieve the display, similar to the following Hyperlink data binding operations. 2. LinkButton display mode:This is only a brief description of its data-bound data display operation. <asp:bulletedlist id= "BulletedList1" runat= "datasourceid=" SqlDataSource1 "datatextfield=" Product Name "datavaluefield=" ProductID displaymode= "LinkButton" > </asp:BulletedList> <asp:sqld Atasource id= "SqlDataSource1" runat= "server" connectionstring= <%$% > "selectcommand=" select top [ProductID], [ProductName] from [Products] > </asp:sqld Atasource> 3. HyperLink display mode:XmlDataSource binding to a BulletedList control as a data source is cumbersome compared to SqlDataSource. Both XmlDataSource and SqlDataSource belong to the new data source control, which is described later.     Suppose an XML data: <?xml version= "1.0" encoding= "Utf-8"?><quicklinks>      <QuickLink>         <name>whidbey @ asp.net</name >         <Url>http://www.asp.net/Whidbey</Url>      </QuickLink>     <QuickLink>          <name>asp.net Dev center</name>         <Url>http://msdn.microsoft.com/asp.net/</Url>     </QuickLink>      <QuickLink>         <name>.net WebLogs @ ASP .net</name>         <Url>http://weblogs.asp.net</Url>      </QuickLink>     <QuickLink>          <name>asp.net Web matrix</name>         <Url >http://asp.net/WebMatrix</Url>     </QuickLink></QuickLinks>     the XSL code corresponding to this XML file is: <xsl:stylesheet version= "1.0" xmlns:xsl= "Http://www.w3.org/1999/XSL/Transform" >     <xsl:template match= "Quicklinks" >          <QuickLinks>              <xsl: Apply-templates select= "QuickLink"/>         </QuickLinks>      </xsl:template>     <xsl:template match= "QuickLink" >          <QuickLink>               <xsl:attribute name= "name" >                    <xsl:value-of select= "Name"/>               </xsl:attribute>               <xsl:attribute name= "Url" >                    <xsl:value-of select= " Url "/>              </xsl:attribute>               <xsl:apply-templates/>          </QuickLink>     </xsl:template ></xsl:stylesheet> bind this XML file to the BulletedList control at this time:             <aSp:xmldatasource id= "XmlDataSource1" runat= "Server" datafile= "~/navigatemenu.xml"                  transformfile= "~/navigatemenu.xsl" xpath= " Quicklinks/quicklink "></asp:XmlDataSource>             <asp:bulletedlist id= "BulletedList1" runat= "Server" datasourceid= "XmlDataSource1"                  datatextfield= "Name" Datavaluefield= "Url" displaymode= "HyperLink" >            </asp:BulletedList> can see from above XmlDataSource except DataFile, It also requires transformfile and the need to specify XPath to be bound to the bulletedlist as a normal data source (other binding xmldatasource such as DropDownList) are similar. In the introduction XmlDataSource will further explain, here first warm body.  [Summary]: As I said at the beginning, for ASP.net 1.x to dynamically display the bulleted list of items, either use the HTML <ol> or <ul> elements, or "overkill" The use of repeater to show. The former is too rigid, the latter too overkill. And BulletedList belong to the "mean" route, just the right control, more than one point is overdone, less a point is notFoot.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.