📄 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 + -