protected void Page_Load(object sender, EventArgs e) { if (int.TryParse(Request.QueryString["pid"], out pid)) { hdPid.Value = pid.ToString(); PhotosBLL pb = new PhotosBLL(); pb.UpdateClicks(pid); Photos p = pb.GetPhotoByPid(pid); if (p != null) { StringBuilder sb = new StringBuilder(); sb.Append("<h1>" + p.PTitle + "</h1>"); sb.Append("<div id='screen'><a href='#'><img src='images/" + p.PUrl + "' alt='' /></a></div>"); sb.Append("<div id='info'><p>" + p.PDes + "</p></div>"); dvContent = sb.ToString(); } else { Response.Write("<script>alert('查询出错!');location.href='index.aspx'</script>"); } } else { Response.Write("<script>alert('参数错误!');location.href='index.aspx'</script>"); } }
private string GetPhotosList() { List<Photos> list = new PhotosBLL().GetPagedPhotos(pageIndex, pageSize, out pageCount); StringBuilder sb = new StringBuilder(); sb.Append("<ul>"); for (int i = 0; i < list.Count; i++) { if ((i + 1) % 3 == 0) { sb.Append("<li class='last'>"); } else { sb.Append("<li>"); } Photos p = list[i]; sb.Append("<div class='name'>" + p.PTitle + "</div>"); sb.Append("<div class='screen'><a href='photos-" + p.PId + ".htm'><img src='createThumbnail.ashx?w=200&h=200&url=" + p.PUrl + "' alt='' /></a></div>"); sb.Append("<div class='vote'>"); sb.Append("<a href='javascript:void(0)' class='up' pid='" + p.PId + "'><img src='images/85.gif' id='up' border='0' /></a>" + "<span>" + p.PUp + "</span>"); sb.Append("<a href='javascript:void(0)' class='down' pid='" + p.PId + "'><img src='../images/86.gif' id='down' border='0' /></a>" + "<span>" + p.PDown + "</span>"); sb.Append("<span>浏览次数:" + p.PClicks+"</span>"); sb.Append("</div>"); sb.Append("</li>"); } sb.Append("</ul>"); sb.Append(PagedClass.Paging(pageCount, pageSize, pageIndex, "GetPagedPhotos.ashx")); sb.Append("</div>"); return sb.ToString(); }
private string GetPhotosList() { List<Photos> list = new PhotosBLL().GetPagedPhotos(pageIndex, pageSize, out pageCount); StringBuilder sb = new StringBuilder(); sb.Append("<table id='tb' cellspacing='0'>"); sb.Append("<tr><th><input type='checkbox' id='cbSelAll' /></th><th>序号</th><th>标题</th><th>照片</th><th>点击次数</th><th>支持</th><th>反对</th><th>时间</th><th>操作</th></tr>"); for (int i = 0; i < list.Count; i++) { sb.Append("<tr>"); Photos p = list[i]; sb.Append("<td><input type='checkbox' pid='" + p.PId + "' /></td>"); sb.Append("<td>" + (i + 1) + "</td>"); sb.Append("<td><a href='PhotoDetail.aspx?pid=" + p.PId + "'>" + p.PTitle + "</a></td>"); sb.Append("<td><a href='PhotoDetail.aspx?pid=" + p.PId + "'><img border='0' src='CreateSmallImage.ashx?path=../images/" + p.PUrl + "' /></a></td>"); sb.Append("<td>" + p.PClicks + "</td>"); sb.Append("<td><a href='UpDown.ashx?type=up&pid=" + p.PId + "'><img src='../images/85.gif' id='up' border='0'/></a>" + p.PUp + "</td>"); sb.Append("<td><a href='UpDown.ashx?type=down&pid=" + p.PId + "'><img src='../images/86.gif' id='down' border='0'/></a>" + p.PDown + "</td>"); sb.Append("<td>" + p.PTime.Value.ToString("yyyy-MM-dd hh:mm:ss") + "</td>"); sb.Append("<td><a href='ModifyPhoto.aspx?pid=" + p.PId + "'>编辑</a> <a href='DeletePhoto.ashx?pid=" + p.PId + "' onclick='return confirm(\"确认删除吗?\")'>删除</a> <a href='DownLoad.ashx?url=" + p.PUrl + "'>下载</a></td>"); sb.Append("</tr>"); } sb.Append("</table>"); sb.Append(PagedClass.Paging(pageCount, pageSize, pageIndex, "Default.aspx")); return sb.ToString(); }
/// <summary> /// 1-更新成功 0-失败 -1-参数错误 /// </summary> /// <param name="context"></param> public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; int pid; if (int.TryParse(context.Request.QueryString["p"], out pid)) { PhotosBLL pb = new PhotosBLL(); string type = context.Request.QueryString["t"]; if (type == "up" || type == "down") { if (pb.UpdateUpDownClicks(type, pid)) { context.Response.Write(1); } else { context.Response.Write(0); } } else { context.Response.Write(-1); } } else { context.Response.Write(-1); } }
protected void Page_Load(object sender, EventArgs e) { List<Photos> list; if (Cache["list"] == null) { list = new PhotosBLL().GetAllPhotos(); //Cache["list"] = list; //string path = Request.MapPath("~/log/TextFile.txt"); //CacheDependency cd = new CacheDependency(path); //Cache.Insert("list", list, cd); System.Web.Caching.SqlCacheDependency dep = new System.Web.Caching.SqlCacheDependency("myphotos", "photos"); Cache.Insert("list", list, dep, System.Web.Caching.Cache.NoAbsoluteExpiration, System.Web.Caching.Cache.NoSlidingExpiration); Response.Write("读取数据库"); } else { list = Cache["list"] as List<Photos>; Response.Write("读取缓存"); } TimeSpan ts = DateTime.Now - Context.Timestamp; Response.Write(ts.TotalMilliseconds + "<br />"); foreach (Photos item in list) { Response.Write(item.PTitle + "<br />"); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; int pid; if (int.TryParse(context.Request.QueryString["pid"], out pid)) { StringBuilder sb = new StringBuilder(); PhotosBLL pb = new PhotosBLL(); pb.UpdateClicks(pid); Photos p = pb.GetPhotoByPid(pid); if (p != null) { List<Comments> list = new CommentsBLL().GetCommentsByPID(pid); if (list != null) { sb.Append("<ul class='commentlist' id='commentslist'>"); for (int i = 0; i < list.Count; i++) { Comments c = list[i]; if (i % 2 == 0) { sb.Append("<li class='comment_odd'>"); } else { sb.Append("<li class='comment_even'>"); } sb.Append("<div class='author'>"); sb.Append("<img class='avatar' src='images/demo/avatar.gif' width='32' height='32' alt='' />"); sb.Append("<span class='name'><a href='#'>" + c.CName + "</a></span>"); sb.Append("<span class='wrote'>wrote:</span>"); sb.Append("</div>"); sb.Append("<div class='submitdate'><a href='#'>" + c.CTime.Value.ToString("yyyy-MM-dd hh:mm:ss") + "</a></div>"); sb.Append("<p>" + c.CText + "</p>"); sb.Append("</li>"); } sb.Append("</ul>"); } context.Response.Write(sb.ToString()); } else { context.Response.Write(-1); } } else { context.Response.Write(-1); } }
protected void Page_Load(object sender, EventArgs e) { StringBuilder sb = new StringBuilder(); if (int.TryParse(Request.QueryString["pid"], out pid)) { PhotosBLL pb = new PhotosBLL(); pb.UpdateClicks(pid); Photos p = pb.GetPhotoByPid(pid); if (p != null) { sb.Append("<table id='tb' cellspaing='0'>"); sb.Append("<tr><td>照片标题</td><td>" + p.PTitle + "</td></tr>"); //sb.Append("<tr><td>照 片</td><td><img src='WaterMaker.ashx?path=" + p.PUrl + "' /></td></tr>"); sb.Append("<tr><td>照 片</td><td><img src='../images/" + p.PUrl + "' /></td></tr>"); sb.Append("<tr><td>照片描述</td><td>" + p.PDes + "</td></tr>"); sb.Append("<tr><td>浏览次数</td><td>" + p.PClicks.Value + "</td></tr>"); sb.Append("<tr><td>支持</td><td>" + p.PUp.Value + "</td></tr>"); sb.Append("<tr><td>反对</td><td>" + p.PDown.Value + "</td></tr>"); sb.Append("<tr><td>添加时间</td><td>" + p.PTime.Value.ToString("yyyy-MM-dd hh:mm:ss") + "</td></tr>"); sb.Append("</table>"); ltbPhoto.Text = sb.ToString(); List<Comments> list = new CommentsBLL().GetCommentsByPID(pid); if (list != null) { StringBuilder sbComments = new System.Text.StringBuilder(); for (int i = 0; i < list.Count; i++) { sbComments.Append("<div class='dvComment'>"); sbComments.Append(list[i].CTime.Value.ToString((i + 1) + "楼 yyyy-MM-dd hh:mm:ss") + "发表<br />"); sbComments.Append(list[i].CText+"<br />"); sbComments.Append("<div class='del'><a href='DelComment.ashx?cid=" + list[i].CId + "&pid=" + list[i].CPhotoId + "' onclick='if(!confirm(\"确定要删除该评论么?\")) return false;' >删除</a></div>"); sbComments.Append("<hr /></div>"); } ltbComments.Text = sbComments.ToString(); } } else { Response.Write("<script>alert('查询出错!');location.href='Default.aspx'</script>"); } } else { Response.Write("<script>alert('参数错误!');location.href='Default.aspx'</script>"); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; int pid; if (int.TryParse(context.Request.QueryString["pid"],out pid)) { Photos p = new PhotosBLL().GetPhotoByPid(pid); JavaScriptSerializer jss = new JavaScriptSerializer(); string json = jss.Serialize(p); context.Response.Write(json); } else { } }
protected void rpt_ItemCommand(object source, RepeaterCommandEventArgs e) { int pid = Convert.ToInt32(e.CommandArgument); PhotosBLL pb = new PhotosBLL(); switch (e.CommandName) { case "up": pb.UpdateUpDownClicks("up", pid); break; case "down": pb.UpdateUpDownClicks("down", pid); break; case "del": pb.Delete(pid); break; } rpt.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int pid; if (int.TryParse(Request.QueryString["pid"], out pid)) { Photos p = new PhotosBLL().GetPhotoByPid(pid); if (p != null) { title = p.PTitle; url = p.PUrl; des = p.PDes; id = p.PId.ToString() ; } else { Response.Write("<script>alert('加载失败!');location.href='Default.aspx'</script>"); } } else { Response.Write("<script>alert('参数错误!');location.href='Default.aspx'</script>"); } } else { Photos p = new Photos(); p.PTitle = Request.Form["txtTitle"]; p.PUrl = Request.Form["url"]; p.PDes = Request.Form["txtDes"]; p.PId = Convert.ToInt32(Request.Form["pid"]); p.PTypeId = 1; if (new PhotosBLL().Update(p)) { Response.Write("<script>alert('修改成功!');location.href='Default.aspx'</script>"); } else { msg.Text = "<script>alert('修改失败');</script>"; } } }
private string GetPhotosList() { List<Photos> list = new PhotosBLL().GetPagedPhotos(pageIndex, pageSize, out pageCount); StringBuilder sb = new StringBuilder(); sb.Append("<table id='tb' cellspacing='0'>"); sb.Append("<tr><th><input type='checkbox' id='cbSelAll' /></th><th>序号</th><th>标题</th><th>照片</th><th>点击次数</th><th>支持</th><th>反对</th><th>时间</th><th>操作</th></tr>"); for (int i = 0; i < list.Count; i++) { sb.Append("<tr>"); Photos p = list[i]; sb.Append("<td><input type='checkbox' pid='" + p.PId + "' /></td>"); sb.Append("<td>" + (i + 1) + "</td>"); sb.Append("<td><a href='PhotoDetail.aspx?pid=" + p.PId + "'>" + p.PTitle + "</a></td>"); sb.Append("<td><a href='PhotoDetail.aspx?pid=" + p.PId + "'><img border='0' src='handlers/CreateSmallImage.ashx?path=../../images/" + p.PUrl + "' /></a></td>"); sb.Append("<td>" + p.PClicks + "</td>"); sb.Append("<td><a href='javascript:void(0)' class='upDown' type='up' pid='" + p.PId + "'><img src='../images/85.gif' id='up' border='0'/></a>" + p.PUp + "</td>"); sb.Append("<td><a href='javascript:void(0)' class='upDown' type='down' pid='" + p.PId + "'><img src='../images/86.gif' id='down' border='0'/></a>" + p.PDown + "</td>"); sb.Append("<td>" + p.PTime.Value.ToString("yyyy-MM-dd hh:mm:ss") + "</td>"); sb.Append("<td><a href='javascript:void(0)' class='edit' pid='" + p.PId + "'>编辑</a> <a href='javascript:void(0)' class='del' pid='" + p.PId + "'>删除</a> <a href='DownLoad.ashx?url=" + p.PUrl + "'>下载</a></td>"); sb.Append("</tr>"); } sb.Append("</table>"); return sb.ToString(); }
protected void Page_Load(object sender, EventArgs e) { List<Photos> list; if (Cache["list"] == null) { list = new PhotosBLL().GetAllPhotos(); Cache["list"] = list; Response.Write("读取数据库"); } else { list = Cache["list"] as List<Photos>; Response.Write("读取缓存"); } TimeSpan ts = DateTime.Now - Context.Timestamp; Response.Write(ts.TotalMilliseconds); foreach (Photos item in list) { Response.Write(item.PTitle + "<br />"); } }