protected void Page_Load(object sender, EventArgs e) { int pageSize = 10; int pageIndex; if (!int.TryParse(Context.Request.QueryString["pageIndex"], out pageIndex)) { pageIndex = 1; } BLL.UserInfoService userInfoServer = new BLL.UserInfoService(); //对当前的页码范围进行判断 int pageCount = userInfoServer.GetPageCount(pageSize); pageIndex = pageIndex < 1 ? 1 : pageIndex; pageIndex = pageIndex > pageCount ? pageCount : pageIndex; PageIndex = pageIndex; PageCount = pageCount; List <UserInfo> list = userInfoServer.GetList(pageIndex, pageSize); StringBuilder sb = new StringBuilder(); foreach (UserInfo item in list) { sb.AppendFormat("<li><span>{0}</span><a href='' target='_blank'>{1}</a></li>", item.RegTime.ToShortDateString(), item.UserName); strHtml = sb.ToString(); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; int pageIndex; if (!int.TryParse(context.Request["pageIndex"], out pageIndex)) { pageIndex = 1; } int pageSize = 10; BLL.UserInfoService userInfoService = new BLL.UserInfoService(); int pageCount = userInfoService.GetPageCount(pageSize); //判断当前页码值得取值范围 pageIndex = pageIndex < 1 ? 1 : pageIndex; pageIndex = pageIndex > pageCount ? pageCount : pageIndex; List <Model.UserInfo> list = userInfoService.GetList(pageIndex, pageSize); string pagebar = Common.PagebarHelper.GetPagebar(pageIndex, pageCount); System.Web.Script.Serialization.JavaScriptSerializer js = new System.Web.Script.Serialization.JavaScriptSerializer(); //序列化和反序列化的类 string str = js.Serialize(new { UList = list, MyPageBar = pagebar }); //将数据序列化成json字符串。匿名类 context.Response.Write(str); }
protected void Page_Load(object sender, EventArgs e) { int id = int.Parse(Request["id"]); BLL.UserInfoService userInfoService = new BLL.UserInfoService(); Model.UserInfo userInfo = userInfoService.GetList(id); List <Model.UserInfo> list = new List <Model.UserInfo>(); list.Add(userInfo); this.DetailsView1.DataSource = list; this.DetailsView1.DataBind(); }
/// <summary> /// 页面加载完成后。load事件 类似WinForm里的Form_Load /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { BLL.UserInfoService userInfoService = new BLL.UserInfoService(); List <Model.UserInfo> userlist = userInfoService.GetList(); List = userlist; //StringBuilder sb = new StringBuilder(); //foreach (Model.UserInfo userInfo in userlist) //{ // sb.AppendFormat("<tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td><a href='UserDetailWebForm.aspx?id={0}'>Detail</a></td><td><a href='javascript:void(0)' onclick= rowDelete(\"{1}\",\"{0}\")>Delete</a></td><td><a href='UpdateUserDetail.ashx?id={0}'>Update</a></td></tr>", userInfo.ID, userInfo.UserName, userInfo.UserPass, userInfo.Email, userInfo.RegTime); //} //StrHtml = sb.ToString(); }
public void GetUserDetailInfo(string ID) { int id; if (int.TryParse(ID, out id)) { BLL.UserInfoService userInfoService = new BLL.UserInfoService(); userInfo = userInfoService.GetList(id); } else { Context.Response.Redirect("/Error.htm"); } }
/// <summary> /// 页面加载完成以后。Load事件 Form_Load /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { BLL.UserInfoService UserInfoService = new BLL.UserInfoService(); List <UserInfo> list = UserInfoService.GetList(); UserList = list; //StringBuilder sb = new StringBuilder(); //foreach (UserInfo userInfo in list) //{ // sb.AppendFormat("<tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td></tr>",userInfo.Id,userInfo.UserName,userInfo.UserPass,userInfo.Email,userInfo.RegTime.ToShortDateString()); //} //StrHtml = sb.ToString(); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string userName = context.Request["userName"]; BLL.UserInfoService userInfoService = new BLL.UserInfoService(); if (userInfoService.GetList(userName) != null) { context.Response.Write("此用户名已存在"); } else { context.Response.Write("此用户名可用"); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; int id; if (int.TryParse(context.Request["id"], out id)) { BLL.UserInfoService userInfoService = new BLL.UserInfoService(); Model.UserInfo userInfo = new Model.UserInfo(); userInfo = userInfoService.GetList(id); System.Web.Script.Serialization.JavaScriptSerializer js = new System.Web.Script.Serialization.JavaScriptSerializer(); context.Response.Write(js.Serialize(userInfo)); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; BLL.UserInfoService userInfoService = new BLL.UserInfoService(); int id; if (int.TryParse(context.Request["id"], out id)) { Model.UserInfo userInfo = new Model.UserInfo(); userInfo = userInfoService.GetList(id); } else { context.Response.Write("no"); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/html"; BLL.UserInfoService userInfoService = new BLL.UserInfoService(); List <UserInfo> list = userInfoService.GetList(); StringBuilder sb = new StringBuilder(); foreach (UserInfo userInfo in list) { sb.AppendFormat("<tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td><a href='ShowUserDetail.ashx?id={0}'>Detail</a></td><td><a href='javascript:void(0)' onclick= rowDelete(\"{1}\",\"{0}\")>Delete</a></td><td><a href='UpdateUserDetail.ashx?id={0}'>Update</a></td></tr>", userInfo.ID, userInfo.UserName, userInfo.UserPass, userInfo.Email, userInfo.RegTime); } string filePath = context.Request.MapPath("UserInfoList.html"); string fileContent = File.ReadAllText(filePath); fileContent = fileContent.Replace("@tboby", sb.ToString()); context.Response.Write(fileContent); }
protected void Page_Load(object sender, EventArgs e) { if (Cache["userInfoList"] == null) { BLL.UserInfoService userInfoService = new BLL.UserInfoService(); List <Model.UserInfo> list = userInfoService.GetList(); //Cache["userInfoList"] = list; Cache.Insert("userInfoList", list, null, DateTime.Now.AddSeconds(10), TimeSpan.Zero, System.Web.Caching.CacheItemPriority.Normal, RemoveCache); Response.Write("数据来自数据库。"); //Cache.Remove("userInfoList"); } else { List <Model.UserInfo> list = (List <Model.UserInfo>)Cache["userInfoList"]; Response.Write("数据来自缓存"); } }
protected void Page_Load(object sender, EventArgs e) { BLL.UserInfoService userInfoService = new BLL.UserInfoService(); List <Model.UserInfo> list = userInfoService.GetList(); this.DropDownList1.DataSource = list; this.DropDownList1.DataTextField = "UserName"; this.DropDownList1.DataValueField = "ID"; this.DropDownList1.DataBind(); StringBuilder sb = new StringBuilder(); foreach (var item in list) { sb.Append("<option value=\"" + item.ID + "\">" + item.UserName + "</option>"); } Str = sb.ToString(); }
protected void Page_Load(object sender, EventArgs e) { BLL.UserInfoService UserInfoService = new BLL.UserInfoService(); List <UserInfo> list = UserInfoService.GetList(); this.DropDownList1.DataSource = list; this.DropDownList1.DataTextField = "UserName"; this.DropDownList1.DataValueField = "Id"; this.DropDownList1.DataBind(); //StringBuilder sb=new StringBuilder(); //foreach(UserInfo userInfo in list) //{ // sb.Append("<option >"+userInfo.UserName+"</option>"); //} Button1.Attributes.Add("onclick", "alert('ssss')"); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/html"; BLL.UserInfoService UserInfoService = new BLL.UserInfoService(); List <UserInfo> list = UserInfoService.GetList(); StringBuilder sb = new StringBuilder(); foreach (UserInfo userInfo in list) { sb.AppendFormat("<tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td><a href='DeleteUser.ashx?id={0}' class='deletes'>删除</a></td><td><a href='ShowDetail.ashx?uid={0}'>详细</a></td><td><a href='ShowEdit.ashx?id={0}'>编辑</a></td></tr>", userInfo.Id, userInfo.UserName, userInfo.UserPass, userInfo.Email, userInfo.RegTime); } //读取模板文件 string filePath = context.Request.MapPath("UserInfoList.html"); string fileCotent = File.ReadAllText(filePath); fileCotent = fileCotent.Replace("@tbody", sb.ToString()); context.Response.Write(fileCotent); }
protected void Page_Load(object sender, EventArgs e) { //判断缓存中是否有数据. if (Cache["userInfoList"] == null) { BLL.UserInfoService UserInfoService = new BLL.UserInfoService(); List <UserInfo> list = UserInfoService.GetList(); //将数据放到缓存中。 // Cache["userInfoList"] = list; Cache.Insert("userInfoList", list, null, DateTime.Now.AddSeconds(5), TimeSpan.Zero, System.Web.Caching.CacheItemPriority.Normal, RemoveCache); Response.Write("数据来自数据库"); //Cache.Remove("userInfoList");//移除缓存 } else { List <UserInfo> list = (List <UserInfo>)Cache["userInfoList"]; } Response.Write("数据来自缓存"); }
protected void Page_Load(object sender, EventArgs e) { int pageIndex; if (!int.TryParse(Request["pageIndex"], out pageIndex)) { pageIndex = 1; } int pageSize = 5; BLL.UserInfoService userInfoService = new BLL.UserInfoService(); int pageCount = userInfoService.GetPageCount(pageSize); pageIndex = pageIndex < 1 ? 1 : pageIndex; pageIndex = pageIndex > pageCount ? pageCount : pageIndex; PageIndex = pageIndex; PageCount = pageCount; this.Repeater1.DataSource = userInfoService.GetList(pageIndex, pageSize); this.Repeater1.DataBind(); }
public void GetUserInfo() { int id; if (int.TryParse(Context.Request.QueryString["ID"], out id)) { userInfo = userInfoService.GetList(id); if (userInfo != null) { userInfoHtml = userInfo; } else { Context.Response.Redirect("/Error.html"); } } else { Context.Response.Write("参数错误"); } }