.net中swith,case开关语句的使用

来源:互联网 发布:淘宝客小程序源码 编辑:程序博客网 时间:2024/05/10 09:18
<%@ Page Language="c#" %>
<script runat="server">

void Page_Load()
{
if (Page.IsPostBack) {
switch(Destination.SelectedItem.Value)
{
case "Barcelona":
Message.Text = "You selected Spain's lively Catalan city";
break;
case "Oslo":
Message.Text = "Experience the majesty of Norway's capital city";
break;
case "Lisbon":
Message.Text = "Portugal's famous seaport and cultural hub";
break;
default:
Message.Text = "you did not select a destination we travel to";
break;
}
}
}

</script>
<html>
<head>
</head>
<body>
<form runat="server">
Select your choice of destination:
<br />
<br />
<asp:radiobuttonlist id="Destination" runat="server">
<asp:listitem>Barcelona</asp:listitem>
<asp:listitem>Oslo</asp:listitem>
<asp:listitem>Lisbon</asp:listitem>
</asp:radiobuttonlist>
<br />
<br />
<input type="submit" value="Submit Choice" />
<br />
<br />
<asp:Label id="Message" runat="server"></asp:Label>
</form>
</body>
</html>