温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:Ajax三级联动和无刷新分页源码
当前文件:
myAjaxDropdownlist/Handler.ashx[2K,2009-6-12 11:48:08],打开代码结构图
myAjaxDropdownlist/Handler.ashx[2K,2009-6-12 11:48:08],打开代码结构图1<%@ WebHandler Language="C#" Class="Handler" %> 2
3
using System; 4
using System.Web; 5
using System.Data.SqlClient; 6
using System.Data; 7
8
public class Handler : IHttpHandler { 9
10
public void ProcessRequest (HttpContext context) { 11
string type = context.Request.QueryString["type"]; 12
if (type.Equals("sheng")) 13
{ 14
string id = context.Request.QueryString["id"]; 15
context.Response.ContentType = "text/plain"; 16
context.Response.Write(getSheng(id));//这个是从数据库中根据传来省的id 查询出来的。市的名字和主键,主键以便去查区的名字 17
} 18
else if (type.Equals("shi")) 19
{ 20
string id = context.Request.QueryString["id"]; 21
context.Response.ContentType = "text/plain"; 22
context.Response.Write(getqu(id)); 23
} 24
} 25
26
public string getqu(string shi) 27
{ 28
DataSet ds = SqlDataAccess.GetAreaInfo(shi); 29
string str = ""; 30
for (int i = 0; i < ds.Tables[0].Rows.Count; i++) 31
{ 32
if (i == ds.Tables[0].Rows.Count - 1) 33
{ 34
str += ds.Tables[0].Rows[i]["code"].ToString() + "," + ds.Tables[0].Rows[i]["name"].ToString(); 35
} 36
else 37
{ 38
str += ds.Tables[0].Rows[i]["code"].ToString() + "," + ds.Tables[0].Rows[i]["name"].ToString() + "|"; 39
} 40
} 41
return str.Trim(); 42
} 43
public string getSheng(string sheng) 44
{ 45
DataSet ds = SqlDataAccess.GetCityInfo(sheng); 46
string str = ""; 47
for (int i = 0; i < ds.Tables[0].Rows.Count; i++) 48
{ 49
if (i == ds.Tables[0].Rows.Count - 1) 50
{ 51
str += ds.Tables[0].Rows[i]["code"].ToString() + "," + ds.Tables[0].Rows[i]["name"].ToString(); 52
} 53
else 54
{ 55
str += ds.Tables[0].Rows[i]["code"].ToString() + "," + ds.Tables[0].Rows[i]["name"].ToString() + "|"; 56
} 57
} 58
return str.Trim(); 59
} 60
61
62
public bool IsReusable { 63
get { 64
return false; 65
} 66
} 67
68
}




