<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="BulletedListDynamicImageTest" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>BulletedList Dynamic Image Test</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2>Simple Bulleted List</h2>
Select a bulleted list style
<asp:DropDownList ID="drpStyles" runat="server" AutoPostBack="true" OnSelectedIndexChanged="drpStyles_SelectedIndexChanged">
<asp:ListItem>Circle</asp:ListItem>
<asp:ListItem>Disc</asp:ListItem>
<asp:ListItem>LowerAlpha</asp:ListItem>
<asp:ListItem>LowerRoman</asp:ListItem>
<asp:ListItem>Numbered</asp:ListItem>
<asp:ListItem>Square</asp:ListItem>
<asp:ListItem>UpperAlpha</asp:ListItem>
<asp:ListItem>UpperRoman</asp:ListItem>
<asp:ListItem>CustomImage</asp:ListItem>
</asp:DropDownList>
<asp:BulletedList ID="blItems" runat="server">
<asp:ListItem>Item 1</asp:ListItem>
<asp:ListItem>Item 2</asp:ListItem>
<asp:ListItem>Item 3</asp:ListItem>
</asp:BulletedList>
</div>
</form>
</body>
</html>
File: Default.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class BulletedListDynamicImageTest : System.Web.UI.Page
{
protected void drpStyles_SelectedIndexChanged(object sender, EventArgs e)
{
string sBullet = drpStyles.SelectedItem.Text;
BulletStyle bs = (BulletStyle)Enum.Parse(typeof(BulletStyle), sBullet, true);
blItems.BulletStyle = bs;
if (bs == BulletStyle.CustomImage){
blItems.BulletImageUrl = "images/bulletPlus.gif";
}
}
}