• <fieldset id="8imwq"><menu id="8imwq"></menu></fieldset>
  • <bdo id="8imwq"><input id="8imwq"></input></bdo>
    最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
    問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
    當前位置: 首頁 - 科技 - 知識百科 - 正文

    Ajax實現無刷新三聯動下拉框

    來源:懂視網 責編:小采 時間:2020-11-27 22:52:43
    文檔

    Ajax實現無刷新三聯動下拉框

    Ajax實現無刷新三聯動下拉框:<HTML> <HEAD> <title>Ajax實現無刷新三聯動下拉框</title> <meta content=Microsoft Visual Studio .NET 7.1 name=GENERATOR> <meta content=C# name=CODE
    推薦度:
    導讀Ajax實現無刷新三聯動下拉框:<HTML> <HEAD> <title>Ajax實現無刷新三聯動下拉框</title> <meta content=Microsoft Visual Studio .NET 7.1 name=GENERATOR> <meta content=C# name=CODE

    <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#region Web Form Designer generated code
    override protected void OnInit(EventArgs e)
    {
    //
    // CODEGEN: This call is required by the ASP.NET Web Form Designer.
    //
    InitializeComponent();
    base.OnInit(e);
    }

    /**//// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()

    this.Load += new System.EventHandler(this.Page_Load);

    }
    #endregion 
    }
    }3.AjaxMethod
    using System;
    using System.Data;
    using System.Data.SqlClient;
    namespace AjaxTest
    {
    /**//// <summary>
    /// Summary description for AjaxMethod.
    /// </summary>
    public class AjaxMethod
    {
    GetProvinceList#region GetProvinceList
    public static DataSet GetProvinceList()
    {
    string sql="select * from province";
    return GetDataSet(sql);
    }
    #endregion

    GetCityList#region GetCityList
    [Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.Read)]
    public DataSet GetCityList(int provinceid)
    {
    string sql="select * from city where father="+provinceid;
    return GetDataSet(sql); 
    }
    #endregion

    GetAreaList#region GetAreaList
    [Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.Read)]
    public DataSet GetAreaList(int cityid)
    {
    string sql="select * from area where father="+cityid;
    return GetDataSet(sql); 
    }
    #endregion

    GetDataSet#region GetDataSet
    public static DataSet GetDataSet(string sql)
    {
    string ConnectionString=System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];
    SqlDataAdapter sda =new SqlDataAdapter(sql,ConnectionString);
    DataSet ds=new DataSet();
    sda.Fill(ds);
    return ds;
    }
    #endregion
    }
    }4.web.config
    <httpHandlers>
    <add verb="POST,GET" path="ajax/*.ashx" type="Ajax.PageHandlerFactory, Ajax" />
    </httpHandlers>5.ajax.dll下載/Files/singlepine/Ajax.rar

    聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

    文檔

    Ajax實現無刷新三聯動下拉框

    Ajax實現無刷新三聯動下拉框:<HTML> <HEAD> <title>Ajax實現無刷新三聯動下拉框</title> <meta content=Microsoft Visual Studio .NET 7.1 name=GENERATOR> <meta content=C# name=CODE
    推薦度:
    • 熱門焦點

    最新推薦

    猜你喜歡

    熱門推薦

    專題
    Top
    主站蜘蛛池模板: 久久久久久无码国产精品中文字幕 | 97久久超碰国产精品2021| wwwvr高清亚洲精品二区| 亚洲av无码国产精品色午夜字幕| 国产国拍亚洲精品福利| 99久久国产热无码精品免费| 中文字幕精品视频在线| 国产精品国产三级国产AⅤ| 99久久免费国产精精品| 亚洲高清国产AV拍精品青青草原| 九九热这里只有国产精品| 夜色www国产精品资源站| AV无码精品一区二区三区| 日韩精品无码久久久久久| 亚洲精品乱码久久久久久不卡| 精品无码国产污污污免费网站国产| 伊人久久综合精品无码AV专区| 亚洲国产精品无码久久98| 老司机精品影院91| 国产偷窥熟女高潮精品视频| 91探花国产综合在线精品| 久久久精品免费国产四虎| laowang在线精品视频| 1024国产欧美日韩精品| 国产精品美女一区二区视频 | 国产精品自在线拍国产手机版| 四虎精品影院4hutv四虎| 国产精品久久久久影视不卡| 6一12呦女精品| 97精品国产手机| 91探花福利精品国产自产在线| 国产精品拍天天在线| 999精品视频这里只有精品| 国产精品夜色一区二区三区 | 97久久久精品综合88久久| 999久久久无码国产精品| 99久久精品日本一区二区免费| 97精品久久天干天天天按摩| 国产99re在线观看只有精品| 国产成人精品免费午夜app| 久久er热视频在这里精品|