Ajax实现无刷新三联动下拉框
2008-10-07 11:33
399 查看
1.html代码
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
<HTML>
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
<HEAD>
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
<title>Ajax实现无刷新三联动下拉框</title>
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
<meta content="C#" name="CODE_LANGUAGE">
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
<meta content="JavaScript" name="vs_defaultClientScript">
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
<SCRIPT language="javascript">
![](http://www.cnblogs.com/Images/dot.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//城市------------------------------
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
function cityResult()
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var city=document.getElementById("DropDownList1");
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
AjaxMethod.GetCityList(city.value,get_city_Result_CallBack);
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
function get_city_Result_CallBack(response)
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
if (response.value != null)
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//debugger;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
document.all("DropDownList2").length=0;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var ds = response.value;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
if(ds != null && typeof(ds) == "object" && ds.Tables != null)
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
for(var i=0; i<ds.Tables[0].Rows.length; i++)
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var name=ds.Tables[0].Rows[i].city;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var id=ds.Tables[0].Rows[i].cityID;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
document.all("DropDownList2").options.add(new Option(name,id));
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//市区----------------------------------------
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
function areaResult()
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var area=document.getElementById("DropDownList2");
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
AjaxMethod.GetAreaList(area.value,get_area_Result_CallBack);
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
function get_area_Result_CallBack(response)
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
if (response.value != null)
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
document.all("DropDownList3").length=0;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var ds = response.value;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
if(ds != null && typeof(ds) == "object" && ds.Tables != null)
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
for(var i=0; i<ds.Tables[0].Rows.length; i++)
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var name=ds.Tables[0].Rows[i].area;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var id=ds.Tables[0].Rows[i].areaID;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
document.all("DropDownList3").options.add(new Option(name,id));
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
function getData()
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var province=document.getElementById("DropDownList1");
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var pindex = province.selectedIndex;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var pValue = province.options[pindex].value;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var pText = province.options[pindex].text;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var city=document.getElementById("DropDownList2");
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var cindex = city.selectedIndex;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var cValue = city.options[cindex].value;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var cText = city.options[cindex].text;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var area=document.getElementById("DropDownList3");
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var aindex = area.selectedIndex;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var aValue = area.options[aindex].value;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var aText = area.options[aindex].text;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var txt=document.getElementById("TextBox1");
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
document.getElementById("<%=TextBox1.ClientID%>").innerText="省:"+pValue+"|"+pText+"市:"+cValue+"|"+cText+"区:"+aValue+"|"+aText;
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
</SCRIPT>
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
</HEAD>
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
<body ms_positioning="GridLayout">
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
<form id="Form1" method="post" runat="server">
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
<TABLE id="Table1" style="Z-INDEX: 101; LEFT: 96px; POSITION: absolute; TOP: 32px" cellSpacing="1"
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
cellPadding="1" width="300" border="1" bgColor="#ccff66">
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
<TR>
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
<TD>省市</TD>
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
<TD><asp:dropdownlist id="DropDownList1" runat="server"></asp:dropdownlist></TD>
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
</TR>
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
<TR>
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
<TD>城市</TD>
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
<TD><asp:dropdownlist id="DropDownList2" runat="server"></asp:dropdownlist></TD>
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
</TR>
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
<TR>
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
<TD>市区</TD>
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
<TD><asp:dropdownlist id="DropDownList3" runat="server"></asp:dropdownlist></TD>
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
</TR>
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
</TABLE>
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
<asp:TextBox id="TextBox1" style="Z-INDEX: 102; LEFT: 416px; POSITION: absolute; TOP: 48px" runat="server"
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
Width="424px"></asp:TextBox><INPUT style="Z-INDEX: 103; LEFT: 456px; WIDTH: 56px; POSITION: absolute; TOP: 96px; HEIGHT: 24px"
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
type="button" value="test" onclick="getData();">
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
</form>
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
</body>
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
</HTML>2.cs代码
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
using System;
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
using System.Collections;
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
using System.ComponentModel;
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
using System.Data;
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
using System.Drawing;
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
using System.Web;
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
using System.Web.SessionState;
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
using System.Web.UI;
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
using System.Web.UI.WebControls;
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
using System.Web.UI.HtmlControls;
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
namespace AjaxTest
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
/**//// <summary>
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
/// Summary description for WebForm1.
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
/// </summary>
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
public class WebForm1 : System.Web.UI.Page
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
protected System.Web.UI.WebControls.DropDownList DropDownList1;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
protected System.Web.UI.WebControls.DropDownList DropDownList2;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
protected System.Web.UI.WebControls.TextBox TextBox1;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
protected System.Web.UI.WebControls.DropDownList DropDownList3;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
private void Page_Load(object sender, System.EventArgs e)
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
Ajax.Utility.RegisterTypeForAjax(typeof(AjaxMethod));
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
if(!Page.IsPostBack)
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this.DropDownList1.DataSource=AjaxMethod.GetProvinceList();
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this.DropDownList1.DataTextField="province";
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this.DropDownList1.DataValueField="provinceID";
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this.DropDownList1.DataBind();
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this.DropDownList1.Attributes.Add("onclick","cityResult();");
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this.DropDownList2.Attributes.Add("onclick","areaResult();");
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
Web Form Designer generated code#region Web Form Designer generated code
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
override protected void OnInit(EventArgs e)
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
InitializeComponent();
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
base.OnInit(e);
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
/**//// <summary>
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
/// Required method for Designer support - do not modify
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
/// the contents of this method with the code editor.
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
/// </summary>
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
private void InitializeComponent()
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this.Load += new System.EventHandler(this.Page_Load);
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
#endregion
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
}3.AjaxMethod
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
using System;
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
using System.Data;
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
using System.Data.SqlClient;
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
namespace AjaxTest
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
/**//// <summary>
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
/// Summary description for AjaxMethod.
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
/// </summary>
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
public class AjaxMethod
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
GetProvinceList#region GetProvinceList
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
public static DataSet GetProvinceList()
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
string sql="select * from province";
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return GetDataSet(sql);
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
#endregion
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
GetCityList#region GetCityList
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.Read)]
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
public DataSet GetCityList(int provinceid)
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
string sql="select * from city where father="+provinceid;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return GetDataSet(sql);
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
#endregion
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
GetAreaList#region GetAreaList
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.Read)]
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
public DataSet GetAreaList(int cityid)
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
string sql="select * from area where father="+cityid;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return GetDataSet(sql);
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
#endregion
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
GetDataSet#region GetDataSet
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
public static DataSet GetDataSet(string sql)
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
string ConnectionString=System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
SqlDataAdapter sda =new SqlDataAdapter(sql,ConnectionString);
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
DataSet ds=new DataSet();
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
sda.Fill(ds);
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return ds;
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
#endregion
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
}4.web.config
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
<httpHandlers>
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
<add verb="POST,GET" path="ajax/*.ashx" type="Ajax.PageHandlerFactory, Ajax" />
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
</httpHandlers>5.ajax.dll下载/Files/singlepine/Ajax.rar
6.真实数据库下载area1.rar
7.源代码下载AjaxTest.rar
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
<HTML>
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
<HEAD>
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
<title>Ajax实现无刷新三联动下拉框</title>
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
<meta content="C#" name="CODE_LANGUAGE">
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
<meta content="JavaScript" name="vs_defaultClientScript">
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
<SCRIPT language="javascript">
![](http://www.cnblogs.com/Images/dot.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//城市------------------------------
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
function cityResult()
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var city=document.getElementById("DropDownList1");
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
AjaxMethod.GetCityList(city.value,get_city_Result_CallBack);
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
function get_city_Result_CallBack(response)
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
if (response.value != null)
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//debugger;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
document.all("DropDownList2").length=0;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var ds = response.value;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
if(ds != null && typeof(ds) == "object" && ds.Tables != null)
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
for(var i=0; i<ds.Tables[0].Rows.length; i++)
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var name=ds.Tables[0].Rows[i].city;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var id=ds.Tables[0].Rows[i].cityID;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
document.all("DropDownList2").options.add(new Option(name,id));
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//市区----------------------------------------
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
function areaResult()
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var area=document.getElementById("DropDownList2");
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
AjaxMethod.GetAreaList(area.value,get_area_Result_CallBack);
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
function get_area_Result_CallBack(response)
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
if (response.value != null)
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
document.all("DropDownList3").length=0;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var ds = response.value;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
if(ds != null && typeof(ds) == "object" && ds.Tables != null)
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
for(var i=0; i<ds.Tables[0].Rows.length; i++)
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var name=ds.Tables[0].Rows[i].area;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var id=ds.Tables[0].Rows[i].areaID;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
document.all("DropDownList3").options.add(new Option(name,id));
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
function getData()
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var province=document.getElementById("DropDownList1");
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var pindex = province.selectedIndex;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var pValue = province.options[pindex].value;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var pText = province.options[pindex].text;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var city=document.getElementById("DropDownList2");
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var cindex = city.selectedIndex;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var cValue = city.options[cindex].value;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var cText = city.options[cindex].text;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var area=document.getElementById("DropDownList3");
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var aindex = area.selectedIndex;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var aValue = area.options[aindex].value;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var aText = area.options[aindex].text;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var txt=document.getElementById("TextBox1");
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
document.getElementById("<%=TextBox1.ClientID%>").innerText="省:"+pValue+"|"+pText+"市:"+cValue+"|"+cText+"区:"+aValue+"|"+aText;
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
</SCRIPT>
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
</HEAD>
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
<body ms_positioning="GridLayout">
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
<form id="Form1" method="post" runat="server">
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
<TABLE id="Table1" style="Z-INDEX: 101; LEFT: 96px; POSITION: absolute; TOP: 32px" cellSpacing="1"
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
cellPadding="1" width="300" border="1" bgColor="#ccff66">
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
<TR>
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
<TD>省市</TD>
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
<TD><asp:dropdownlist id="DropDownList1" runat="server"></asp:dropdownlist></TD>
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
</TR>
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
<TR>
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
<TD>城市</TD>
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
<TD><asp:dropdownlist id="DropDownList2" runat="server"></asp:dropdownlist></TD>
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
</TR>
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
<TR>
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
<TD>市区</TD>
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
<TD><asp:dropdownlist id="DropDownList3" runat="server"></asp:dropdownlist></TD>
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
</TR>
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
</TABLE>
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
<asp:TextBox id="TextBox1" style="Z-INDEX: 102; LEFT: 416px; POSITION: absolute; TOP: 48px" runat="server"
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
Width="424px"></asp:TextBox><INPUT style="Z-INDEX: 103; LEFT: 456px; WIDTH: 56px; POSITION: absolute; TOP: 96px; HEIGHT: 24px"
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
type="button" value="test" onclick="getData();">
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
</form>
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
</body>
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
</HTML>2.cs代码
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
using System;
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
using System.Collections;
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
using System.ComponentModel;
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
using System.Data;
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
using System.Drawing;
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
using System.Web;
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
using System.Web.SessionState;
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
using System.Web.UI;
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
using System.Web.UI.WebControls;
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
using System.Web.UI.HtmlControls;
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
namespace AjaxTest
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
/**//// <summary>
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
/// Summary description for WebForm1.
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
/// </summary>
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
public class WebForm1 : System.Web.UI.Page
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
protected System.Web.UI.WebControls.DropDownList DropDownList1;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
protected System.Web.UI.WebControls.DropDownList DropDownList2;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
protected System.Web.UI.WebControls.TextBox TextBox1;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
protected System.Web.UI.WebControls.DropDownList DropDownList3;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
private void Page_Load(object sender, System.EventArgs e)
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
Ajax.Utility.RegisterTypeForAjax(typeof(AjaxMethod));
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
if(!Page.IsPostBack)
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this.DropDownList1.DataSource=AjaxMethod.GetProvinceList();
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this.DropDownList1.DataTextField="province";
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this.DropDownList1.DataValueField="provinceID";
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this.DropDownList1.DataBind();
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this.DropDownList1.Attributes.Add("onclick","cityResult();");
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this.DropDownList2.Attributes.Add("onclick","areaResult();");
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
Web Form Designer generated code#region Web Form Designer generated code
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
override protected void OnInit(EventArgs e)
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
InitializeComponent();
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
base.OnInit(e);
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
/**//// <summary>
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
/// Required method for Designer support - do not modify
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
/// the contents of this method with the code editor.
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
/// </summary>
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
private void InitializeComponent()
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this.Load += new System.EventHandler(this.Page_Load);
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
#endregion
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
}3.AjaxMethod
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
using System;
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
using System.Data;
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
using System.Data.SqlClient;
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
namespace AjaxTest
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
/**//// <summary>
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
/// Summary description for AjaxMethod.
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
/// </summary>
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
public class AjaxMethod
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
GetProvinceList#region GetProvinceList
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
public static DataSet GetProvinceList()
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
string sql="select * from province";
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return GetDataSet(sql);
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
#endregion
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
GetCityList#region GetCityList
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.Read)]
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
public DataSet GetCityList(int provinceid)
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
string sql="select * from city where father="+provinceid;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return GetDataSet(sql);
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
#endregion
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
GetAreaList#region GetAreaList
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.Read)]
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
public DataSet GetAreaList(int cityid)
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
string sql="select * from area where father="+cityid;
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return GetDataSet(sql);
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
#endregion
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
GetDataSet#region GetDataSet
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
public static DataSet GetDataSet(string sql)
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://www.cnblogs.com/Images/dot.gif)
{
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
string ConnectionString=System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
SqlDataAdapter sda =new SqlDataAdapter(sql,ConnectionString);
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
DataSet ds=new DataSet();
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
sda.Fill(ds);
![](http://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return ds;
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
#endregion
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
}4.web.config
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
<httpHandlers>
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
<add verb="POST,GET" path="ajax/*.ashx" type="Ajax.PageHandlerFactory, Ajax" />
![](http://www.cnblogs.com/Images/OutliningIndicators/None.gif)
</httpHandlers>5.ajax.dll下载/Files/singlepine/Ajax.rar
6.真实数据库下载area1.rar
7.源代码下载AjaxTest.rar
相关文章推荐
- Ajax实现无刷新三联动下拉框
- Ajax实现无刷新三联动下拉框
- Ajax实现无刷新的三联动下拉框
- Ajax实现无刷新三联动下拉框
- Ajax实现无刷新三联动下拉框
- Ajax实现无刷新三联动下拉框
- Ajax实现无刷新三联动下拉框
- Ajax实现无刷新三联动下拉框
- Ajax+Servlet实现无刷新下拉联动
- 用Ajax.net实现的一个无刷新的多级联动下拉列表框
- Ajax实现无刷新三联动下拉框
- Ajax实现无刷新三联动下拉框
- Ajax实现无刷新三联动下拉框 VS2005 ASP.NET DropDownList
- Ajax实现无刷新三联动下拉框
- Ajax实现无刷新三联动下拉框
- Ajax实现无刷新三联动下拉框
- 【Ajax实现无刷新三联动下拉框】
- Ajax实现无刷新三联动下拉框
- Ajax实现无刷新三联动下拉框
- 用Ajax.net实现的一个无刷新的多级联动下拉列表框