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

📄 news.ashx

📁 news新闻系统. news新闻系统 news新闻系统
💻 ASHX
字号:
<%@ WebHandler Language="C#" Class="news" %>

using System;
using System.Web;
using System.Data;
using News.BLL;
using System.Collections;
using Newtonsoft.Json;

public class news : IHttpHandler {

    int page;   //页码
    int rows;   //行数
    int tableCount;   //数据行数
    int pageCount;      //多少页
    ArrayList arlRow = new ArrayList();     //  数据数组
    Hashtable htGrid = new Hashtable();     //数据hash  table   
    
    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "text/plain";
        page = Convert.ToInt32(context.Request.QueryString["page"]);
       rows = Convert.ToInt32(context.Request.QueryString["rows"]);
       // rows = 3;
        newsMuiBLL bll = new newsMuiBLL();
        //HttpCookie cookie = new HttpCookie();
        //string code = cookie["code"].ToString();
        string code = "cn";
        DataTable dt = new DataTable(); 
        GetType Get_type = new GetType();
        if (string.IsNullOrEmpty(context.Request.QueryString["keyword"]))
        {
             dt = bll.Select(code).Tables[0];
        }
        else 
        {
            string _key = Get_type.Encode(context.Request.QueryString["keyword"]);
            dt = bll.Select(code, _key).Tables[0];
         }
    
        tableCount = dt.Rows.Count;
        pageCount = tableCount == 0 || tableCount < rows ? 1 : tableCount / rows; //计算多少页
        htGrid.Add("total", pageCount);
        htGrid.Add("page", page);
        htGrid.Add("records", tableCount);
       
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            System.Collections.ArrayList arlCell = new ArrayList();
            arlCell.Add(dt.Rows[i]["news_category_id"].ToString());
            arlCell.Add(dt.Rows[i]["new_title"].ToString());
            arlCell.Add(dt.Rows[i]["new_releasDate"].ToString());
            arlCell.Add(dt.Rows[i]["new_Update"].ToString());
            arlCell.Add(dt.Rows[i]["new_status"].ToString());
            System.Collections.Hashtable ht = new System.Collections.Hashtable();
            ht.Add("id", dt.Rows[i]["news_category_id"].ToString());
            ht.Add("cell", arlCell);
            arlRow.Add(ht);
        }
        htGrid.Add("rows", arlRow);
        context.Response.Write(JavaScriptConvert.SerializeObject(htGrid));
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}

⌨️ 快捷键说明

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