日期:2014-05-17  浏览次数:20500 次

JS市无刷新联动
自己对JS不是蛮熟,然后现在要把市实现无刷新联动,我自己在cs文件里已经写出了刷新联动,然后要把市实现无刷新联动
这是CS里面的代码

这是显示默认的
C# code

if (!IsPostBack)
            {
                RegionalInformation ri = new RegionalInformation();

                
                string[][] allProvinces = ri.GetProvinces();

                for (int i = 0; i < allProvinces.Length; i++)
                {
                    ListItem lip = new ListItem(allProvinces[i][1], allProvinces[i][0]);
                    DDLProvince.Items.Add(lip);
                    
                }

                string[][] citiesOfProvince = ri.GetCitiesOfProvince("1");
                for (int j = 0; j < citiesOfProvince.Length; j++)
                {
                    ListItem li = new ListItem(citiesOfProvince[j][1], citiesOfProvince[j][0]);
                    DDLCity.Items.Add(li);
                }
           }



联动市的信息,就是要把我在cs里面写的市联动信息,用JS写,要无刷新,自己对JS不熟不知要如何实现
C# code

protected void DDLProvince_SelectedIndexChanged(object sender, EventArgs e)
        {
            RegionalInformation ri = new RegionalInformation();
            string a = Convert.ToString(DDLProvince.SelectedIndex + 1);

            string[][] citiesOfProvince = ri.GetCitiesOfProvince(a);
            DDLCity.Items.Clear();
            for (int j = 0; j < citiesOfProvince.Length; j++)
            {
                ListItem li = new ListItem(citiesOfProvince[j][1], citiesOfProvince[j][0]);
                DDLCity.Items.Add(li);
            }
        }




后台代码
HTML code

 <asp:DropDownList ID="DDLProvince" runat="server" CssClass="select" 
               AutoPostBack="True" Height="22px" 
               onselectedindexchanged="DDLProvince_SelectedIndexChanged" Width="150px">
           </asp:DropDownList>
           <asp:DropDownList ID="DDLCity" runat="server" CssClass="select" 
               CausesValidation="True" Height="22px" Width="150px">
           </asp:DropDownList>



------解决方案--------------------
你这个得用ajax来做 具体代码就不写了 去百度找找 一大把的