主题:再有一段运行不了的代码,麻烦
<%@ Page Language="C#" %>
<script runat="server">
void Page_Load()
{
string msgCitiesList="";
If(Page.IsPostBack==true)
If(list1.Item(0).Selected==true)
{
msgCitiesList=msgCitiesList+list1.Items(0).Text&"<br/>";
}
If (list1.Items(1).Selected==true)
{
msgCitiesList ="msgCitiesList+list1.Items(0).Text&"<br/>;
If(list1.Items(2).Selected==true)
{
msgCitiesList=msgCitiesList+list1.Items(0).Text&"<br/>"
}
If(msgCitiesList!="")
{
Message.Text="You have selected:<br/>"+msgCitiesList;
}
else
{
Message.Text="";
}
}
</script>
<html>
<head>
<title>List Box Example</title>
</head>
<body>
<asp:Label id="Message" runat="server"></asp:Label>
<br />
Which city do you wish to look at hotels for?<br />
<form runat="server">
<asp:listbox id="list1" runat="server" mode="multiple" selection="selection">
<asp:listitem>Madrid</asp:listitem>
<asp:listitem>Oslo</asp:listitem>
<asp:listitem>Lisbon</asp:listitem>
</asp:listbox>
</form>
</body>
</html>
<script runat="server">
void Page_Load()
{
string msgCitiesList="";
If(Page.IsPostBack==true)
If(list1.Item(0).Selected==true)
{
msgCitiesList=msgCitiesList+list1.Items(0).Text&"<br/>";
}
If (list1.Items(1).Selected==true)
{
msgCitiesList ="msgCitiesList+list1.Items(0).Text&"<br/>;
If(list1.Items(2).Selected==true)
{
msgCitiesList=msgCitiesList+list1.Items(0).Text&"<br/>"
}
If(msgCitiesList!="")
{
Message.Text="You have selected:<br/>"+msgCitiesList;
}
else
{
Message.Text="";
}
}
</script>
<html>
<head>
<title>List Box Example</title>
</head>
<body>
<asp:Label id="Message" runat="server"></asp:Label>
<br />
Which city do you wish to look at hotels for?<br />
<form runat="server">
<asp:listbox id="list1" runat="server" mode="multiple" selection="selection">
<asp:listitem>Madrid</asp:listitem>
<asp:listitem>Oslo</asp:listitem>
<asp:listitem>Lisbon</asp:listitem>
</asp:listbox>
</form>
</body>
</html>