<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" ScriptMode="Auto" EnablePartialRendering="true"> </asp:ScriptManager> <div> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <div id="city" style="position:relative; float:left; width:450px"> <div style="position:relative; margin-right:10px; margin-top:20px; float:left"><span style="float:left">State:</span><br /> <asp:DropDownList CssClass="dropdown" ID="st" style="vertical-align:middle" Font-Size="14px" Width="215px" Height="20px" runat="server" AutoPostBack="True" onselectedindexchanged="st_SelectedIndexChanged" > <asp:ListItem>a</asp:ListItem> <asp:ListItem>b</asp:ListItem> <asp:ListItem>c</asp:ListItem> <asp:ListItem>d</asp:ListItem> <asp:ListItem>e</asp:ListItem> </asp:DropDownList></div><div style="position:relative; margin-top:20px; float:left"><span style="float:left">City:</span><br /> <asp:DropDownList CssClass="dropdown" ID="cty" Font-Size="14px" Width="200px" Height="20px" runat="server" AutoPostBack="True"></asp:DropDownList></div> </div> </ContentTemplate> </asp:UpdatePanel> </div> </form> </body> </html>
using System; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void st_SelectedIndexChanged(object sender, EventArgs e) { if (st.SelectedValue == "a") { cty.Items.Add("d"); } if (st.SelectedValue == "b") { cty.Items.Add("c"); } if (st.SelectedValue == "c") { cty.Items.Add("b"); } if (st.SelectedValue == "d") { cty.Items.Add("a"); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)