关于c#的问题请高手帮忙。

来源:百度知道 编辑:UC知道 时间:2024/05/11 20:02:30
<script runat="server" language="C#">
void Page_Load()
{
string msg = "You have selected: <br />";

if (list1.Items[0].Selected) {
msg = msg + list1.Items[0].Text + "<br />";
}
if (list1.Items[1].Selected) {
msg = msg + list1.Items[1].Text + "<br />";
}
if (list1.Items[2].Selected) {
msg = msg + list1.Items[2].Text + "<br />";
}
Message.Text = msg;
}
</script>
<html>
<head>
<title>Drop Down List Example</title>
</head>
<body>
<asp:label id="Message" runat="server"/>
<br />
<form runat="server">
Which city do you wish to look at hotels for?<br /><br />
<asp:listbox id=&quo

<script runat="server" language="C#">
void Page_Load()
{
string msg = "You have selected: <br />";

if (list1.Items[0].Selected) {
msg = msg + list1.Items[0].Text + "<br />";
}
if (list1.Items[1].Selected) {
msg = msg + list1.Items[1].Text + "<br />";
}
if (list1.Items[2].Selected) {
msg = msg + list1.Items[2].Text + "<br />";
}
Message.Text = msg;
}
</script>

//这段代码等于aspx里面的
protected void Page_Load(object sender, EventArgs e)
{
string msg = "You have selected: <br />";

if (list1.Items[0].Selected) {
msg = msg + list1.Items[0].Text + "<br />";
}
if (list1.Items[1].Selected) {
msg = msg + list1.Items[1].Text + "<br />";
}
if (list1.Items[2].Selected) {
msg = msg + list1.Items[2].