清清月儿 .NET万花筒 Asp.net技术 Asp.net教程 Asp.net源码 Asp.net基础 Asp.net控件 Asp.net入门

天下事有难易乎?为之,则难者亦易矣;不为,则易者亦难矣。

用户操作
[即时聊天] [发私信] [加为好友]
清清月儿ID:21aspnet
2117063次访问,排名5,好友12人,关注者622人。
21aspnet的文章
原创 970 篇
翻译 9 篇
转载 33 篇
评论 1412 篇
清清月儿的公告
最近评论
haoyg123:我是新手,写的相当好啊,受益非浅哪。
redfox241:这个真的好用马?
你用过没有?就知道拿来用!!!
yynju:顶楼主的好文,网站的效率非常关键!
yinyaling:看完您的文章,受益非浅啊
huximing:这里的东西真多,一下子是看不完的,先收藏了
文章分类
收藏
    相册
    图片库
    图片库2
    .NET 工具
    C# to VB.NET Translator
    Fiddler
    FxCop代码标准检测工具
    httpwatch
    ieinspector
    IETester
    Memcached
    Multiple IE
    Nbear
    Nunit单元测试
    pushlets
    Tab集合
    VB.NET and C# Comparison
    VB.NET 代码转为C#
    网站国际排名查询工具
    .NET 下载/讲座视频
    chinaitlab
    enfull
    Visual Studio 2005 的工具
    wrox出版社书刊代码下载
    中国台湾微软MSDN
    中文MSDN WebCast网络广播全部下载列表
    源码之家
    .NET 优秀Blog
    cathsfz
    cnkiminzhuhu
    cuike519的专栏
    dahuzizyd的专栏
    DotNet技术交流乐园
    DotNet男孩社区
    dudu
    gztoby
    IT Crazy
    Kemin's booootLog
    kimyoo(RSS)
    Leoo2sk
    LoveCherry
    MSDN每日追踪
    Nios.Org
    Teddy's Knowledge Base
    Think Different and Think More
    Visual Studio.net专栏
    WCF Tools 中国研发团队的专栏
    体验ASP.NET 2.0新特性
    刘洪峰
    天轰穿
    孟宪会
    宝玉
    开心就好【博客堂】
    张子阳
    思归呓语
    木子 [I am praying]
    李会军
    李洪根【VB】
    永春阁
    汉飞扬【Vista】
    涂曙光【SharePoint】
    理想&美人(RSS)
    维生素C.net
    网际浪子
    葛涵涛
    蒋涛
    蝈蝈俊.net[csdn版]
    蝈蝈俊.net[joycode版]
    谭振林
    邹建
    阿不
    阿良.NET
    雨痕
    風語·深蓝
    鸟食轩(RSS)
    黄昕
    .NET 优秀网站
    .NET 官方网www.asp.net
    .NET 藏经阁 - 知识分享
    .NET开发资源精华收【不得不看】
    ASP .NET FAQ
    asp101
    aspfree
    C#开源资源
    C#开源资源大全
    C#语言在线帮助网站
    codeproject
    infragistics
    Internet Explorer 开发者资源
    iwebsms
    MSDN Web/服务
    MSDN中文
    Scott Guthrie(ASP.NET之父)
    SharePoint爱好者
    VS2005.com
    Wintellect
    www.411asp.net
    世界上最大的Open Source项目在线网站
    中国C#技术学习中心
    官方ASP.NET入门教程
    微软中文新闻组
    微软官方.NET指导站点
    最好的索引网站
    正则
    邮件发送常见问题解决方法
    Ajax链接
    AJAX载入等待图片在线生成
    bindows(RSS)
    DHTML menu4作者主页(RSS)
    Dhtmlgoodies
    Dynamicdrive
    EXT类库
    json
    Tabs
    Tabs
    Tabs
    Yahoo YUI
    大量DHTML代码
    无忧脚本 - JavaScript
    索漫
    综合开发技术网
    CSDN
    IBM中文Web 项目资源中心
    W3C技术在中国
    中国BS网
    中文C#技术站
    天新网
    天极网开发频道
    太平洋电脑网web开发
    看雪
    统一教学网
    编程爱好者
    网页设计师:web标准教程及推广,网站重构
    老猫理想
    蓝色理想
    豆豆技术网
    赛迪网
    存档
    软件项目交易
    订阅我的博客
    XML聚合  FeedSky
    订阅到鲜果
    订阅到Google
    订阅到抓虾
    订阅到BlogLines
    订阅到Yahoo
    订阅到GouGou
    订阅到飞鸽
    订阅到Rojo
    订阅到newsgator
    订阅到netvibes

    原创 Ajax实现无刷新三联动下拉框 收藏

    新一篇: Ajax.NET的几个示例代码  | 旧一篇: Ajax简单示例之改变下拉框动态生成表格


    1.html代码
    <HTML>
        
    <HEAD>
            
    <title>Ajax实现无刷新三联动下拉框</title>
            
    <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
            
    <meta content="C#" name="CODE_LANGUAGE">
            
    <meta content="JavaScript" name="vs_defaultClientScript">
            
    <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
            
    <SCRIPT language="javascript">            
                
    //城市------------------------------
                function cityResult() 
                

                    
    var city=document.getElementById("DropDownList1");
                    AjaxMethod.GetCityList(city.value,get_city_Result_CallBack);
                }

                
                
    function get_city_Result_CallBack(response)
                
    {
                    
    if (response.value != null)
                    
    {                    
                        
    //debugger;
                        document.all("DropDownList2").length=0;                
                    
    var ds = response.value;
                        
    if(ds != null && typeof(ds) == "object" && ds.Tables != null)
                        
    {                    
                            
    for(var i=0; i<ds.Tables[0].Rows.length; i++)
                        
    {
                            
    var name=ds.Tables[0].Rows[i].city;
                          
    var id=ds.Tables[0].Rows[i].cityID;
                          document.all(
    "DropDownList2").options.add(new Option(name,id));
                        }

                        }

                    }
                    
                    
    return
                }

                
    //市区----------------------------------------
                function areaResult() 
                

                    
    var area=document.getElementById("DropDownList2");
                    AjaxMethod.GetAreaList(area.value,get_area_Result_CallBack);
                }

                
    function get_area_Result_CallBack(response)
                
    {
                    
    if (response.value != null)
                    
    {                    
                        document.all(
    "DropDownList3").length=0;                
                    
    var ds = response.value;
                        
    if(ds != null && typeof(ds) == "object" && ds.Tables != null)
                        
    {                    
                            
    for(var i=0; i<ds.Tables[0].Rows.length; i++)
                        
    {
                          
    var name=ds.Tables[0].Rows[i].area;
                          
    var id=ds.Tables[0].Rows[i].areaID;
                          document.all(
    "DropDownList3").options.add(new Option(name,id));
                        }
                    
                        }

                    }

                    
    return
                }

                
    function getData()
                
    {
                    
    var province=document.getElementById("DropDownList1");
                    
    var pindex = province.selectedIndex;
                    
    var pValue = province.options[pindex].value;
                    
    var pText  = province.options[pindex].text;
                    
                    
    var city=document.getElementById("DropDownList2");
                    
    var cindex = city.selectedIndex;
                    
    var cValue = city.options[cindex].value;
                    
    var cText  = city.options[cindex].text;
                    
                    
    var area=document.getElementById("DropDownList3");
                    
    var aindex = area.selectedIndex;
                    
    var aValue = area.options[aindex].value;
                    
    var aText  = area.options[aindex].text;
                    
                    
    var txt=document.getElementById("TextBox1");                                

                    document.getElementById(
    "<%=TextBox1.ClientID%>").innerText="省:"+pValue+"|"+pText+"市:"+cValue+"|"+cText+"区:"+aValue+"|"+aText;
                }

            
    </SCRIPT>
        
    </HEAD>
        
    <body ms_positioning="GridLayout">
            
    <form id="Form1" method="post" runat="server">
                
    <TABLE id="Table1" style="Z-INDEX: 101; LEFT: 96px; POSITION: absolute; TOP: 32px" cellSpacing="1"
                    cellPadding
    ="1" width="300" border="1" bgColor="#ccff66">
                    
    <TR>
                        
    <TD>省市</TD>
                        
    <TD><asp:dropdownlist id="DropDownList1" runat="server"></asp:dropdownlist></TD>
                    
    </TR>
                    
    <TR>
                        
    <TD>城市</TD>
                        
    <TD><asp:dropdownlist id="DropDownList2" runat="server"></asp:dropdownlist></TD>
                    
    </TR>
                    
    <TR>
                        
    <TD>市区</TD>
                        
    <TD><asp:dropdownlist id="DropDownList3" runat="server"></asp:dropdownlist></TD>
                    
    </TR>
                
    </TABLE>
                
    <asp:TextBox id="TextBox1" style="Z-INDEX: 102; LEFT: 416px; POSITION: absolute; TOP: 48px" runat="server"
                    Width
    ="424px"></asp:TextBox><INPUT style="Z-INDEX: 103; LEFT: 456px; WIDTH: 56px; POSITION: absolute; TOP: 96px; HEIGHT: 24px"
                    type
    ="button" value="test" onclick="getData();">
            
    </form>
        
    </body>
    </HTML>
    2.cs代码
    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Web;
    using System.Web.SessionState;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;
    namespace AjaxTest
    {
        
    /// <summary>
        
    /// Summary description for WebForm1.
        
    /// </summary>

        public class WebForm1 : System.Web.UI.Page
        
    {
            
    protected System.Web.UI.WebControls.DropDownList DropDownList1;
            
    protected System.Web.UI.WebControls.DropDownList DropDownList2;
            
    protected System.Web.UI.WebControls.TextBox TextBox1;
            
    protected System.Web.UI.WebControls.DropDownList DropDownList3;
        
            
    private void Page_Load(object sender, System.EventArgs e)
            
    {    
                Ajax.Utility.RegisterTypeForAjax(
    typeof(AjaxMethod));
                
    if(!Page.IsPostBack)
                
    {
                    
    this.DropDownList1.DataSource=AjaxMethod.GetProvinceList();
                    
    this.DropDownList1.DataTextField="province";
                    
    this.DropDownList1.DataValueField="provinceID";
                    
    this.DropDownList1.DataBind();
                    
                    
    this.DropDownList1.Attributes.Add("onclick","cityResult();");
                    
    this.DropDownList2.Attributes.Add("onclick","areaResult();");
                }

            }


            
    Web Form Designer generated code        
        }