<%@ WebHandler Language="C#" Class="CheckPriKey" %> using System; using System.Collections.Generic; using System.Web; using System.Data; using System.IO; using eMIS.Data; using System.Data.Common; using System.Text; using System.Web.SessionState; using eMIS; public class CheckPriKey : IHttpHandler, IRequiresSessionState { public void ProcessRequest (HttpContext context) { string menuId = context.Request.QueryString["id"].ToString(); string pk = context.Request.QueryString["pk"].ToString(); string ck = context.Request.QueryString["ck"].ToString(); InstanceManager inst = new InstanceManager(context,menuId); inst.AllowSaveState = true; string list = inst.GetStateValue("spk"); if (ck == "1") list = add(list, pk); else if (ck == "0") list = del(list, pk); else list = pk; inst.SetStateValue("spk", list); context.Response.ContentType = "text/plain"; context.Response.ContentEncoding = System.Text.Encoding.UTF8; context.Response.Write(list); } public string del(string list,string pk) { string s = list; if (s != "") { s = "," + list + ","; if (s.Contains("," + pk + ",")) s = s.Replace("," + pk + ",", ","); s = s.Substring(1, s.Length - 2); } return s; } public string add(string list,string pk) { string s = list; if (s != "") { s = "," + list + ","; if (!s.Contains("," + pk + ",")) s += pk+","; s = s.Substring(1, s.Length - 2); } else { s = pk; } return s; } public bool IsReusable { get { return false; } } }