?? handler.ashx
字號:
?<%@ WebHandler Language="C#" Class="Handler" %>
using System;
using System.Web;
public class Handler : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/xml";
string PovinceID = context.Request["id"];
Data db = new Data();
System.Data.DataTable AimDt = db.GetCity(PovinceID);
System.Text.StringBuilder xml = new System.Text.StringBuilder();
xml.Append("<?xml version=\"1.0\" encoding=\"utf-8\" ?><Root>");
for (int i = 0; i < AimDt.Rows.Count; i++)
{
xml.Append("<citys>");
for (int j = 0; j < AimDt.Columns.Count; j++)
{
string caption = AimDt.Columns[j].Caption;
string text = AimDt.Rows[i][j].ToString();
xml.Append("<" + caption + ">" + text + "</" + caption + ">");
}
xml.Append("</citys>");
}
xml.Append("</Root>");
context.Response.Write(xml.ToString());
}
public bool IsReusable
{
get {
return false;
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -