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

谁能给一个dropDownList 二级无刷新联动的例子?
开始用UpdatePanel,虽然页面不刷新了,但DropDownList任然会闪动,这不是我所想要的效果;
有没谁谁能给一个DropDownList无刷新联动的例子,两个DropDownlist都要从数据库中调用数据,可以用AJAX技术。
不要告诉我网上的示例很多,其实网上的都是一大抄,没有多少是可以用的。

------解决方案--------------------
你也说Ajax技术可以 为什么不用了 使用UpdatePanel控件 实现局部刷新
------解决方案--------------------
用ajaxpro很简单的 上网随便搜下 ajaxpro 二级联动 很多

不要告诉我网上的示例很多,其实网上的都是一大抄,没有多少是可以用的。

其实是你不会搜关键字
------解决方案--------------------
http://topic.csdn.net/u/20090417/12/6cf0d4ee-70a6-45f4-ae52-ba49fe3af32b.html
------解决方案--------------------
网上搜js实现二级联动!
------解决方案--------------------
到51aspx上去下載嗎,有現成的例子:下載地址:thunder://QUFodHRwOi8vYWxsLjUxYXNweC5jb20vRHJvcERvd25MaXN0VlMyMDA4LnJhclpa
------解决方案--------------------
脚本代码
function SFchange()//省份选择变换
{
var sf = document.getElementById("SF");
var city = document.getElementById('city');
document.getElementById('city').innerText = "";
document.getElementById('city').value = "";
for(var i=0;i<sf.options.length;i++ > 0) 
{
sf.options[i] = null; 
}
if(sf.value != "")

var ds = AjaxCZ.GetSFInfor(sf.value).value;//ajax获取省份下的市

if(ds!=null && ds.Tables!=null&&typeof(ds)=="object" )
{
city.options.add(new Option("",""));//添加一个空节点
for(var i=0;i<ds.Tables[0].Rows.length;i++)
{
city.options.add(new Option(ds.Tables[0].Rows[i].SFMC,ds.Tables[0].Rows[i].SFID));//SFMC省份名称,SFID省份ID
}


}
}
//html代码
<asp:dropdownlist id="SF" onchange="SFchange();" runat="server" Width="100%" asp:dropdownlist>
<asp:dropdownlist id="city" runat="server" Width="100%" asp:dropdownlist>



------解决方案--------------------
注册AjaxCZ类
Ajax.Utility.RegisterTypeForAjax(typeof(AjaxCZ));

Class AjaxCZ
{
[Ajax.AjaxMethod()]
public DataSet GetSFInfor(string sf)
{
return DataSet;//具体自己写,就是根据省份取的下面的城市
}
}
我是直接在网页上写的例子,楼主记得给分
------解决方案--------------------
http://blog.csdn.net/wangjun8868/archive/2008/09/26/2983149.aspx
------解决方案--------------------
探讨
你也说Ajax技术可以 为什么不用了 使用UpdatePanel控件 实现局部刷新

------解决方案--------------------
用ajax吧,这么好的技术不用
------解决方案--------------------
DropDownList会闪动的,因为局部postback。

用jquery的AJAX或者自己写一堆js
------解决方案--------------------
我来接分。。。
前台页面:
C# code

        <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
        </asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:DropDownList ID="ddlFather" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlFather_SelectedIndexChanged"></asp:DropDownList>
                <asp:DropDownList ID="ddlSon" runat="server"></asp:DropDownList>
            </ContentTemplate>
        </asp:UpdatePanel>