web应用的一些Ajax操作

仅仅列出JQuery部分和一般处理程序部分。web原型就是我的个人任务管理系统

JQuery:

 
    
    

一般处理程序:

删除:

public class deleteTask : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            var requset = context.Request;
            var id = Convert.ToInt32(requset.Form["id"]);
            var res = TaskManage.Delete(id);
            context.Response.ContentType = "application/json";
            context.Response.Write(res);
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }

获取列表:

public void ProcessRequest(HttpContext context)
        {
            var requset = context.Request;
            var id = Convert.ToInt32(requset.QueryString["id"]);
            var state = Convert.ToInt32(requset.QueryString["state"]);
            var content = requset.QueryString["content"];
            var table = TaskManage.Select(id, state, content);
            List list = new List();
            foreach (DataRow row in table.Rows)
            {
                var data = new
                {
                    AddTime = Convert.ToDateTime(row["AddTime"]).ToString("yyyy/MM/dd HH:mm:ss"),
                    Content = Convert.ToString(row["Content"]),
                    FinishedTime = row["FinishedTime"] == DBNull.Value ? "" : Convert.ToDateTime(row["FinishedTime"]).ToString("yyyy/MM/dd HH:mm:ss"),
                    ProjectID = Convert.ToInt32(row["ProjectID"]),
                    ProjectName = Convert.ToString(row["ProjectName"]),
                    TaskID = Convert.ToInt32(row["TaskID"]),
                    TaskPrioriry = TaskPrioriry(Convert.ToInt32(row["TaskPrioriry"])),
                    TaskState = Convert.ToInt32(row["TaskState"])
                };
                list.Add(data);
            }
            var ser = new JavaScriptSerializer();
            var res = ser.Serialize(list);
            context.Response.ContentType = "application/json";
            context.Response.Write(res);
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }

更新: 

 

 public class uodateTask2 : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            var requset = context.Request;
            var id = Convert.ToInt32(requset.Form["id"]);
            var res = TaskManage.Update(new Task() { TaskID = id });
            context.Response.ContentType = "application/json";
            context.Response.Write(res);
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }

 

你可能感兴趣的:(c#)