CopyPastehas never been so tasty!

BulletedList Control in Asp.Net 3.5

by anonymous

  • 0
  • 0
  • 0
102 views

 
BulletedList.aspx file:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="BulletedList.aspx.cs" Inherits="BulletedList" %>
 
<!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">
 
<body>
 
  <h3>BulletedList</h3>
 
  <form id="form1" runat="server">
 
    <p>Click on one item plz.</p> 
 
    <asp:BulletedList id="Bulletedlist" 
      BulletStyle="Disc"
      DisplayMode="LinkButton"
      runat="server" onclick="Bulletedlist_Click">
        <asp:ListItem Value="http://www.codingvilla.com">Coding Villa</asp:ListItem>
        <asp:ListItem Value="http://www.smspunch.com/">Sms Punch</asp:ListItem>
        <asp:ListItem Value="http://www.intellisoftsolutions.com">Intellisoft Solutions</asp:ListItem>
        
    </asp:BulletedList>
 
    <asp:Label id="Message" 
      Font-Size="12"
      Width="168px" 
      Font-Bold="True" 
      runat="server"
      AssociatedControlID="Bulletedlist"/>
 
   </form>
 
</body>
</html>
Code behind file:
using System;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
 
public partial class BulletedList : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
 
    }
    protected void Bulletedlist_Click(object sender, BulletedListEventArgs e)
    {
        switch (e.Index)
        {
            case 0:
                Message.Text = "You clicked on Coding Villa";
                break;
            case 1:
                Message.Text = "You clicked on Sms Punch";
                break;
            case 2:
                Message.Text = "You clicked on Intellisoft Solutions";
                break;
            default:
                throw new Exception("You did not click a valid list item");
                break;
               
        }
    }
}

Add A Comment: