首先聲明的下拉列表
<asp:DropDownList ID="ddlDestination" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddl_SelectedIndexChanged">
<asp:ListItem Text="Select Destination" Selected="True" />
<asp:ListItem Text="Go To Google.com" Value="http://www.google.com" />
<asp:ListItem Text="Go To Yahoo.com" Value="http://www.yahoo.com" />
<asp:ListItem Text="Go To stackoverflow.com" Value="http://www.stackoverflow.com" />
</asp:DropDownList>
其次,在背後把這段代碼的代碼
protected void ddl_SelectedIndexChanged(object sender, EventArgs e)
{
if (ddlDestination.SelectedIndex > 0)
{
string goToWebsite = ddlDestination.SelectedValue;
Response.Redirect(goToWebsite);
}
}
希望這有助於
可能我需要'changesList.SelectedIndex改變+ =' – draw