ASP.NET v2.0: Introducing BulletedList Control
page 5 of 5
by Colt Kwong
Feedback
Average Rating: 
Views (Total / Last 10 Days): 34691/ 70

Different Usage of BulletedList Control

Different Usage of BulletedList Control

In addition to display item / text value in a bullet format width different styles, you can also create a list of HyperLink and LinkButton from it by changing its DisplayMode properties:

  • Text
  • HyperLink
  • LinkButton

The name of the DisplayMode property explain its nature and use obviously, and the following two examples can show its features:

  • HyperLink

    HTML:

    <form runat="server">
       
           <asp:bulletedlist id="BulletedList1" runat="server"
            displaymode="HyperLink"
            datasourceid="Datasetdatasource1"
            datatextfield="Name"
            datavaluefield="Url" />
        <br />
       
        <asp:datasetdatasource id="Datasetdatasource1" runat="server"
            datafile="NavigationMenu.xml" />
               
    </form>


    NavigationMenu.xml

    <?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>



    Screen Shot:

  • LinkButton


    HTML:

<form runat="server">

    <h2>Download Presentation/Demo</h2>

   

<asp:bulletedlist id="demoBulletedList" runat="server"

displaymode="LinkButton"

bulletstyle="Numbered"

tooltip="Download Demo"

onclick="Bulletedlist1_Click">

 

<asp:ListItem>ASP.NET Tips & Tricks</asp:ListItem>
<
asp:ListItem>Operating & Deploying ASP.NET Applications </asp:ListItem><asp:ListItem>ASP.NET Http Runtime </asp:ListItem>

<asp:ListItem>Building Custom ASP.NET Server Controls </asp:ListItem>

 

    </asp:bulletedlist>

   

    <br />

   

    <asp:label id="messageLabel" runat="Server" />

</form>


Server Code:

 

void Bulletedlist1_Click(object sender, System.Web.UI.WebControls.BulletedListEventArgs e) {

    // WriteFile here

    messageLabel.Text = "You've downloaded the Presenation # " + (e.Index + 1).ToString() ;                             

}



Screen Shot:

 

Conclusion

One of the features of ASP.NET v2.0 is developer productivity, while the creation of BulletedList control is obviously save a lots of codes to be written and a common feedback of existing ASP.NET 1.* developers.

With the use of datasourceid property of the BulletedList control, developer can retrieve data from anyDataSourceControl and display them in a bullet format easily in ASP.NET v2.0

The addition of (SmartTag) wizard for server control provide a user friendly configuration tool for developers. This BulletedList control can save the development time and avoid the overkill of repeater control as in ASP.NET 1.*

 

Version Note

This article was based on an early Alpha release of ASP.NET v2.0 and VS.NET Whidbey. It is possible that some implementation or v1.* compatibility details will change.


View Entire Article

User Comments

Title: Direct Post   
Name: Icer
Date: 2007-03-20 5:17:40 AM
Comment:
It is pretty easy to redirect to another page: (The display style has to be "Hyperlink")

ListItem item = new ListItem(Title, Url);
BulletedList.Items.Add(item);

That´s it.
Title: Controlling URL in Hyperlink mode   
Name: Patrick Farrell
Date: 2007-02-26 12:36:37 PM
Comment:
In response to Russ's comments. Although it's not necessarily intuitive, when you are using the BulletedList and you have the display mode set to URL, ListItem.Value renders the link url, ListItem.Text renders the display.

http://patf.net/blogs
Title: Images do not exist   
Name: Ozma
Date: 2006-03-22 2:18:56 PM
Comment:
The images in this article are no longer at the URLs used in the markup
Title: Still Can't Post Directly to Another Page   
Name: Russ Brooks
Date: 2006-03-19 3:08:08 PM
Comment:
The control is essentially useless because we still can not post driectly to another page. Like most .NET controls, why isn't there an "Url" attribute and a way to append a query string? True we can use the onclick, capture the event in the code-behind, then redirect with an appended query string, but why cause two requests on the server and skew logging and traffic metrics? Even 5 years after the advent of .NET, Microsoft still thinks a website can be built with a single page.

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2022 ASPAlliance.com  |  Page Processed at 2022-10-06 4:23:57 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search