简单教程
提交运行
代码编辑器:
<script runat="server"> sub Page_Load if Not Page.IsPostBack then dim mycountries=New ArrayList mycountries.Add("Norway") mycountries.Add("Sweden") mycountries.Add("France") mycountries.Add("Italy") mycountries.TrimToSize() mycountries.Sort() dd.DataSource=mycountries dd.DataBind() end if end sub sub displayMessage(s as Object,e As EventArgs) lbl1.text="Your favorite country is: " & dd.SelectedItem.Text end sub </script> <!DOCTYPE html> <meta charset="utf-8" /> <form runat="server"> <asp:DropDownList id="dd" runat="server" AutoPostBack="True" onSelectedIndexChanged="displayMessage" /> <p><asp:label id="lbl1" runat="server" /></p> </form>
运行结果: