<%@ WebHandler Language="C#" Class="getFunction" %> using System; using System.Web; using System.Web.SessionState; using System.Data; using System.Text; using System.Collections; using System.Collections.Generic; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Curtain.DataAccess; using DK.XuWei.WebMes; public class getFunction : IHttpHandler, IReadOnlySessionState { public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; using(IDataAccess conn = DataAccess.Create()) { DataTable dt = conn.ExecuteDatatable(@" SELECT FUNCTIONCODE AS id, FUNCTIONCODE AS code, FUNCTIONNAME AS text, URL AS url FROM TP_SYS_FUNCTION WHERE IS_WEB = '1' ORDER BY FUNCTIONLEVEL, FUNCTIONCODE "); string rootId = dt.Rows[0]["id"].ToString(); string rootCode = dt.Rows[0]["code"].ToString(); string rootText = dt.Rows[0]["text"].ToString(); string children = Easyui.TableToEasyUITree(dt, rootCode); string jsonStr = "[{\"id\":\"" + rootId + "\",\"text\":\"" + rootText + "\"" + children + "}]"; context.Response.Write(jsonStr); } } public bool IsReusable { get { return false; } } }