我把代码贴出来,请帮我修改正确,谢谢!<script language="c#" runat="server">
void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
label1.Text = "You selected " + DropDownList1.SelectedItem.Text;
}
</script>
......
<form runat="server">
<asp:DropDownList id="DropDownList1"
AutoPostBack="true" runat="server">
<asp:ListItem>Item 1</asp:ListItem>
<asp:ListItem>Item 2</asp:ListItem>
<asp:ListItem>Item 3</asp:ListItem>
<asp:ListItem>Item 4</asp:ListItem>
</asp:DropDownList>
<asp:label ID="label1" runat="server"/>
</form>
void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
label1.Text = "You selected " + DropDownList1.SelectedItem.Text;
}
</script>
......
<form runat="server">
<asp:DropDownList id="DropDownList1"
AutoPostBack="true" runat="server">
<asp:ListItem>Item 1</asp:ListItem>
<asp:ListItem>Item 2</asp:ListItem>
<asp:ListItem>Item 3</asp:ListItem>
<asp:ListItem>Item 4</asp:ListItem>
</asp:DropDownList>
<asp:label ID="label1" runat="server"/>
</form>
AutoPostBack="true" runat="server" OnChange="DropDownList1_SelectedIndexChanged">
<asp:DropDownList id="DropDownList1" AutoPostBack="true" runat="server" OnSelectedIndexChanged ="DropDownList1_SelectedIndexChanged">
label1.Text = "You selected " + DropDownList1.SelectedItem.Text;
<asp:ListItem Value="1999">1999</asp:ListItem>
<asp:ListItem Value="2000">2000</asp:ListItem>
</asp:DropDownList>
属性窗口在加入OnSelectedIndexChanged事件
AutoPostBack="true" runat="server" OnChange="DropDownList1_SelectedIndexChanged">