All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
为什么PHP令人不爽(对于大型系统)_php资料_编程技术
SQL数据操作基础(初级)1_mssql学习_编程技术
在,GridView,中增加记录的方法_[Asp.Net教程]
如何使用Ajax技术开发Web应用程序_[AJAX教程]
asp.net,2.0中不同web控件之间的相互调用_[Asp.Net教程]
ASP.NET中的Response对象的方法_.net资料_编程技术
GridView显示服务器图片(保存为图片路径)_[Asp.Net教程]
ASP.NET多频道网站架构实现方法_.net资料_编程技术
ADO.NET与数据源连接的对象Connection
实现在页面中单击按钮关闭页面_[Asp.Net教程]
Reading number is top 10 pictures
每天进步一点点
A man's favorite things5
你是左脑型还是右脑型
这才是真正的人体艺术2
这年头,找个靠谱的妹子太难了
采访谢楠
Sora aoi mirror memorial classics3
关于海盗的研究
China's first snake village2
赵惟依写真1
Download software ranking
Unix video tutorial6
Unix video tutorial19
The Bermuda triangle1
Be there or be square
Unix video tutorial14
linux安装大全
C语言教程TXT
Tram sex maniac 2 (H) rar bag1
C#编程思想
linux高级编程
归海一刀 published in(发表于) 2014/1/30 0:51:00 Edit(编辑)
Ajax实现无刷新三联动下拉框_[Asp.Net教程]

Ajax实现无刷新三联动下拉框_[Asp.Net教程]

Ajax实现无刷新三联动下拉框_[Asp.Net教程]


1.html代码




Ajax实现无刷新三联动下拉框









cellPadding="1" width="300" border="1" bgColor="#ccff66">



省市









城市









市区








Width="424px"> type="button" value="test" onclick="getData();">



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 description for WebForm1.
///

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);
}

/**////


/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

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 description for AjaxMethod.
///

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



5.ajax.dll下载/Files/singlepine/Ajax.rar
6.真实数据库下载area1.rar
7.源代码下载AjaxTest.rar


来源:cnblogs







添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.