前台代码<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!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>無題のページ</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>
BulletedList Control
</h1>
<asp:BulletedList ID="bltList" runat="server" Target="_blank" OnClick="bltList_Click">
<asp:ListItem Value="http://www.163.com/">
网易
</asp:ListItem>
<asp:ListItem Value="http://vc.hanghai.com/index.asp">
航海世紀
</asp:ListItem>
<asp:ListItem Value="http://www.baidu.com/" Text="百度">
</asp:ListItem>
</asp:BulletedList>
<table>
<tr>
<td colspan="3" id="tdMessage" runat="server">
</td>
</tr>
<tr>
<td>
BulletedStyle
</td>
<td>
FristBulletNumber
</td>
<td>
DisplayMode
</td>
</tr>
<tr>
<td>
<asp:ListBox ID="lbBulletStyle" runat="server" AutoPostBack="True" OnSelectedIndexChanged="lb_SelectedIndexChanged">
<asp:ListItem>NotSet
</asp:ListItem>
<asp:ListItem>Numberd
</asp:ListItem>
<asp:ListItem>LowerAlpha
</asp:ListItem>
<asp:ListItem>UpperAlpha
</asp:ListItem>
<asp:ListItem>LowerRoman
</asp:ListItem>
<asp:ListItem>UpperRoman
</asp:ListItem>
<asp:ListItem>Disc
</asp:ListItem>
<asp:ListItem>Cricle
</asp:ListItem>
<asp:ListItem>Square
</asp:ListItem>
<asp:ListItem>CustomImage
</asp:ListItem>
</asp:ListBox>
</td>
<td >
<asp:ListBox ID="lbFristBulletNumber" runat="server" AutoPostBack="True" Width="50" OnSelectedIndexChanged="lb_SelectedIndexChanged">
<asp:ListItem>1
</asp:ListItem>
<asp:ListItem>2
</asp:ListItem>
<asp:ListItem>3
</asp:ListItem>
<asp:ListItem>4
</asp:ListItem>
<asp:ListItem>5
</asp:ListItem>
<asp:ListItem>6
</asp:ListItem>
</asp:ListBox>
</td>
<td>
<asp:ListBox ID="lbDisplayMode" runat="server" AutoPostBack="True" OnSelectedIndexChanged="lb_SelectedIndexChanged">
<asp:ListItem>NotSet
</asp:ListItem>
<asp:ListItem>Text
</asp:ListItem>
<asp:ListItem>HyperLink
</asp:ListItem>
<asp:ListItem>LinkButton
</asp:ListItem>
</asp:ListBox>
</td>
</tr>
</table>
</div>
</form>
</body>
</html> 后台的代码:protected void lb_SelectedIndexChanged(object sender, EventArgs e)
{
ListBox lb = (ListBox)sender;
string strID = lb.ID;
string strValue = lb.SelectedValue;
switch (strID)
{
case"lbBulletStyle":
BulletStyle style = (BulletStyle)Enum.Parse(typeof(BulletStyle), strValue);
bltList.BulletStyle = style;
if (style == BulletStyle.CustomImage)
{
bltList.BulletImageUrl = "heart.bmp";
}
break;
case"lbFristBulletNumber":
bltList.FirstBulletNumber = Convert.ToInt32(strValue);
break;
case "lbDisplayMode":
BulletedListDisplayMode displayMode = (BulletedListDisplayMode)Enum.Parse(typeof(BulletedListDisplayMode), strValue);
bltList.DisplayMode = displayMode;
break;
default:
break;
}
} protected void bltList_Click(object sender, BulletedListEventArgs e)
{
BulletedList b = (BulletedList)sender;
tdMessage.InnerHtml = "selected index:" + e.Index.ToString() + "selected value:" + b.Items[e.Index].Value + "<br>";
}这些case 中的部分看不懂,请各位大虾指点指点~~
<head runat="server">
<title>無題のページ</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>
BulletedList Control
</h1>
<asp:BulletedList ID="bltList" runat="server" Target="_blank" OnClick="bltList_Click">
<asp:ListItem Value="http://www.163.com/">
网易
</asp:ListItem>
<asp:ListItem Value="http://vc.hanghai.com/index.asp">
航海世紀
</asp:ListItem>
<asp:ListItem Value="http://www.baidu.com/" Text="百度">
</asp:ListItem>
</asp:BulletedList>
<table>
<tr>
<td colspan="3" id="tdMessage" runat="server">
</td>
</tr>
<tr>
<td>
BulletedStyle
</td>
<td>
FristBulletNumber
</td>
<td>
DisplayMode
</td>
</tr>
<tr>
<td>
<asp:ListBox ID="lbBulletStyle" runat="server" AutoPostBack="True" OnSelectedIndexChanged="lb_SelectedIndexChanged">
<asp:ListItem>NotSet
</asp:ListItem>
<asp:ListItem>Numberd
</asp:ListItem>
<asp:ListItem>LowerAlpha
</asp:ListItem>
<asp:ListItem>UpperAlpha
</asp:ListItem>
<asp:ListItem>LowerRoman
</asp:ListItem>
<asp:ListItem>UpperRoman
</asp:ListItem>
<asp:ListItem>Disc
</asp:ListItem>
<asp:ListItem>Cricle
</asp:ListItem>
<asp:ListItem>Square
</asp:ListItem>
<asp:ListItem>CustomImage
</asp:ListItem>
</asp:ListBox>
</td>
<td >
<asp:ListBox ID="lbFristBulletNumber" runat="server" AutoPostBack="True" Width="50" OnSelectedIndexChanged="lb_SelectedIndexChanged">
<asp:ListItem>1
</asp:ListItem>
<asp:ListItem>2
</asp:ListItem>
<asp:ListItem>3
</asp:ListItem>
<asp:ListItem>4
</asp:ListItem>
<asp:ListItem>5
</asp:ListItem>
<asp:ListItem>6
</asp:ListItem>
</asp:ListBox>
</td>
<td>
<asp:ListBox ID="lbDisplayMode" runat="server" AutoPostBack="True" OnSelectedIndexChanged="lb_SelectedIndexChanged">
<asp:ListItem>NotSet
</asp:ListItem>
<asp:ListItem>Text
</asp:ListItem>
<asp:ListItem>HyperLink
</asp:ListItem>
<asp:ListItem>LinkButton
</asp:ListItem>
</asp:ListBox>
</td>
</tr>
</table>
</div>
</form>
</body>
</html> 后台的代码:protected void lb_SelectedIndexChanged(object sender, EventArgs e)
{
ListBox lb = (ListBox)sender;
string strID = lb.ID;
string strValue = lb.SelectedValue;
switch (strID)
{
case"lbBulletStyle":
BulletStyle style = (BulletStyle)Enum.Parse(typeof(BulletStyle), strValue);
bltList.BulletStyle = style;
if (style == BulletStyle.CustomImage)
{
bltList.BulletImageUrl = "heart.bmp";
}
break;
case"lbFristBulletNumber":
bltList.FirstBulletNumber = Convert.ToInt32(strValue);
break;
case "lbDisplayMode":
BulletedListDisplayMode displayMode = (BulletedListDisplayMode)Enum.Parse(typeof(BulletedListDisplayMode), strValue);
bltList.DisplayMode = displayMode;
break;
default:
break;
}
} protected void bltList_Click(object sender, BulletedListEventArgs e)
{
BulletedList b = (BulletedList)sender;
tdMessage.InnerHtml = "selected index:" + e.Index.ToString() + "selected value:" + b.Items[e.Index].Value + "<br>";
}这些case 中的部分看不懂,请各位大虾指点指点~~
哪句话不懂
请指点指点~~~
{
case"lbBulletStyle":
这就一根据strID的不同值选择case啊~有什么不懂的?具体点说嘛
bltList.BulletStyle = style;
不懂之二:
bltList.FirstBulletNumber = Convert.ToInt32(strValue);
不懂之三:
BulletedListDisplayMode displayMode = (BulletedListDisplayMode)Enum.Parse(typeof(BulletedListDisplayMode), strValue);
bltList.DisplayMode = displayMode;
bltList.BulletStyle = style;
不懂之二:
bltList.FirstBulletNumber = Convert.ToInt32(strValue);
不懂之三:
BulletedListDisplayMode displayMode = (BulletedListDisplayMode)Enum.Parse(typeof(BulletedListDisplayMode), strValue);
bltList.DisplayMode = displayMode;
--------------------------------------------------------------------这些不都是类型转换吗?有什么不懂的?