⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 handler.ashx

📁 Ajax三级联动和无刷新分页源码,数据库操作采用的是SqlHelper
💻 ASHX
字号:
<%@ 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));//这个是从数据库中根据传来省的id 查询出来的。市的名字和主键,主键以便去查区的名字
        }
        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;
        }
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -