<script language="C#" runat="server">
protected void Page_Load(object o, EventArgs e) {
if(!IsPostBack) {
ArrayList arrayList = new ArrayList();
arrayList.Add("C#");
arrayList.Add("VB.NET");
arrayList.Add("JScript.Net");
languageDropDownList.DataSource = arrayList;
languageDropDownList.DataBind();
favoriteLanguage.Text = languageDropDownList.SelectedItem.Value;
}
}
protected void DropDownListSelectionChanged(object o, EventArgs e) {
favoriteLanguage.Text = languageDropDownList.SelectedItem.Text;
}
</script>
<form runat="server">
<asp:DropDownList
id="languageDropDownList"
runat="server"
OnSelectedIndexChanged="DropDownListSelectionChanged" >
</asp:DropDownList><br/>
Favorite Language: <b><asp:Label runat="server" id="favoriteLanguage" style="color:blue" /></b><br />
<asp:Button runat="server" Text="Submit"/>
</form>
|