?? handler.ashx
字號(hào):
?<%@ WebHandler Language="C#" Class="Handler" %>
using System;
using System.Web;
using System.Data.SqlClient;
using System.Data;
public class Handler : IHttpHandler {
public void ProcessRequest (HttpContext context) {
string type = context.Request.QueryString["type"];
if (type.Equals("sheng"))
{
string id = context.Request.QueryString["id"];
context.Response.ContentType = "text/plain";
context.Response.Write(getSheng(id));//這個(gè)是從數(shù)據(jù)庫中根據(jù)傳來省的id 查詢出來的。市的名字和主鍵,主鍵以便去查區(qū)的名字
}
else if (type.Equals("shi"))
{
string id = context.Request.QueryString["id"];
context.Response.ContentType = "text/plain";
context.Response.Write(getqu(id));
}
}
public string getqu(string shi)
{
DataSet ds = SqlDataAccess.GetAreaInfo(shi);
string str = "";
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
if (i == ds.Tables[0].Rows.Count - 1)
{
str += ds.Tables[0].Rows[i]["code"].ToString() + "," + ds.Tables[0].Rows[i]["name"].ToString();
}
else
{
str += ds.Tables[0].Rows[i]["code"].ToString() + "," + ds.Tables[0].Rows[i]["name"].ToString() + "|";
}
}
return str.Trim();
}
public string getSheng(string sheng)
{
DataSet ds = SqlDataAccess.GetCityInfo(sheng);
string str = "";
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
if (i == ds.Tables[0].Rows.Count - 1)
{
str += ds.Tables[0].Rows[i]["code"].ToString() + "," + ds.Tables[0].Rows[i]["name"].ToString();
}
else
{
str += ds.Tables[0].Rows[i]["code"].ToString() + "," + ds.Tables[0].Rows[i]["name"].ToString() + "|";
}
}
return str.Trim();
}
public bool IsReusable {
get {
return false;
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -