1-后台代码
using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using DataAccess; using Beyondbit.CService.WebControls; namespace WebSite.Common { public partial class cmjjjc_ggl_list : System.Web.UI.Page { DAOWeb_Content daoContent = new DAOWeb_Content(); DAOWeb_Subject daoSubject = new DAOWeb_Subject(); DataTable _dataTable; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Search(); } } protected void TPager1_PageChanged(object sender, PageChangedEventArgs e) { Search(); } private void Search() { try { int count = 0; TPager1.PageSize = 20; this.Repeater1.Visible = true; this.hidtr.Visible = false; _dataTable = daoContent.GetSubstringInfo(TPager1.PageSize, this.TPager1.CurrentPageIndex + 1, ref count); if (_dataTable.Rows.Count > 0) { ViewState["dt"] = _dataTable; Repeater1.DataSource = _dataTable; Repeater1.DataBind(); this.TPager1.RecordCount = count; } else { this.hidtr.Visible = true; this.Repeater1.Visible = false; } } catch (Exception ex) { Response.Write("<script>alert('" + ex.ToString() + "')</script>"); } } } }
1-前台代码
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="cmjjjc_ggl_list.aspx.cs" Inherits="WebSite.Common.cmjjjc_ggl_list" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>无标题页</title> <style type="text/css"> .td a { float: left; 600px; color: #595959; text-decoration: none; font-size: 12px; font-family: 微软雅黑; line-height: 24px; list-style-type: none; } .td a:hover { color: #0087d0; text-decoration: underline; font-family: 微软雅黑; line-height: 24px; list-style-type: none; } .time { color: #b7b6b6; font-size: 12px; font-family: 微软雅黑; line-height: 24px; list-style-type: none; 70px; float: right; } </style> </head> <body> <form id="form1" runat="server"> <div> <table width="100%" border="0" cellpadding="0" cellspacing="0" align="center"> <asp:Repeater ID="Repeater1" runat="server"> <ItemTemplate> <tr style="padding-bottom:10px; line-height:0px;"> <td class="td a" style="line-height:0px;"> <a href="http://www.cnblogs.com/http://www.cnblogs.com/common/cmjjjc_ggl_detail.aspx?id=<%# DataBinder.Eval(Container.DataItem, "va") %>&code=<%# DataBinder.Eval(Container.DataItem, "vd") %>" target="_blank"> <%# DataBinder.Eval(Container.DataItem, "vb") %></a> <span class="time" style="line-height:15px;"> <%# DataBinder.Eval(Container.DataItem, "vc") %></span> </td> </tr> </ItemTemplate> </asp:Repeater> <tr runat="server" id="hidtr" visible="false"> <td colspan="2" align="center" style="height: 50px; font-family: 微软雅黑; font-size: 12px; line-height: 24px; list-style-type: none;"> 本栏目暂无信息 </td> </tr> <tr> <td colspan="2" style="height: 15px"> </td> </tr> <tr> <td colspan="2" align="center" style=" 100%; float: left; padding-left: 0px; padding-top: 10px; text-align: center; font-size: 12px; font-family: 微软雅黑; line-height: 24px; padding-bottom: 10px; border-top-color: #d0cfc9; border-top-style: solid; border-top- 1px;"> 分页控件添加上 </td> </tr> </table> </div> </form> </body> </html>
2-前台代码
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="cmjjjc_ggl_detail.aspx.cs" Inherits="WebSite.Common.cmjjjc_ggl_detail" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>崇明纪检监察</title> <link href="../html/cmjjjc/styles/cmjjjc.css" rel="stylesheet" type="text/css" /> <style type="text/css"> .STYLE17 { color: #999999; font-size: 12px; font-weight: normal; } .ctitle { font-family: 宋体; font-size: 18px; font-weight: bold; } .bg_02 table { 100%; } #tablebolder { border-color: #000000; 800px; } #tablebolder td { border-color: #000000; } </style> </head> <body> <form id="form1" runat="server"> <div class="wrap"> <!--[if lte IE 6]> <style type="text/css"> .menu ul li a:hover {color:#ffffff;background-color:#d33001;} .menu ul li a:hover ul {display:block; position:absolute;top:29px; left:0;background-color:#d33001;border:#CC6F11 solid 1px; border-top:0px;} .menu ul li a:hover ul li a {display:block;color:#ffffff; height:auto;103px;font:normal 12px/24px "宋体";background-color:#d33001;} .menu ul li a:hover ul li a.drop {background:#CF0B01;} .menu ul li a:hover ul li a ul {visibility:hidden; position:absolute; height:0; 0;} .menu ul li a:hover ul li {border-top:solid 1px #dd4200;} .menu ul li a:hover ul li a:hover {color:yellow;} .menu ul li a:hover ul li a:hover ul {visibility:visible; position:absolute; top:0; color:yellow;left:100px;} .menu ul li a:hover ul li a:hover ul.left {left:-100px;} </style> <![endif]--> <div class="head"> <div class="banner"> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="1000" height="138"> <param name="wmode" value="opaque" /> <param name="movie" value="../html/cmjjjc/images/head.swf" /> <param name="quality" value="high"> <embed src="../html/cmjjjc/images/head.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="777" height="85" style="z-index: 100" wmode="opaque"></embed> </object> </div> <table width="1000" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF"> <tr> <td valign="top" style="padding-top: 5px; padding-bottom: 5px;"> </td> </tr> <td valign="top" style="padding-top: 5px; padding-bottom: 5px;"> <table width="100%" border="0" cellpadding="10" cellspacing="10" class="bg_02"> <tr> <td> <div align="center"> <table> <tr> <td class="ctitle" style="height: 40px;" runat="server" id="tdtitle"> </td> </tr> <tr> <td class="ctitle" style="height: 40px; font-size: 15px;" id="subtitle" runat="server"> </td> </tr> <tr> <td class="STYLE17" style="height: 40px;" runat="server" id="tdtime"> 来源: <div runat="server" id="divsource"> </div> </td> </tr> </table> </div> </td> </tr> <tr> <td style="font-size: 14px; font-weight: normal; line-height: 24px;" runat="server" id="tdcontent"> </td> </tr> <tr> <td> <div class="divattach" id="attachname" style="float:left;" runat="server"> 【附件下载】<br /> </div> </td> </tr> <tr> <td> <div align="center"> <img src="../html/cmjjjc/images/dy.gif" width="54" height="21" style="cursor: hand;" onclick="window.print();" /> <img src="../html/cmjjjc/images/ck.gif" width="54" height="21" style="cursor: hand;" onclick="window.close();" /></div> </td> </tr> </table> </td> </tr> </table> </div> </div> </form> </body> </html>
2-后台代码
using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using DataAccess; using DataCommon; namespace WebSite.Common { public partial class cmjjjc_ggl_detail : System.Web.UI.Page { DAO_DownstageUsers dao_downstageusers = new DAO_DownstageUsers(); DAOWeb_Content _daocontent = new DAOWeb_Content(); DAOWeb_ContentSubject _daocontentsub = new DAOWeb_ContentSubject(); DAOWeb_Pubattach _pubattach = new DAOWeb_Pubattach(); DAOWeb_Subject _daosubject = new DAOWeb_Subject(); protected void Page_Load(object sender, EventArgs e) { int id = Request.QueryString["id"] == null ? -1 : Convert.ToInt32(Request.QueryString["id"]); string code = Request.QueryString["code"] == null ? "" : Request.QueryString["code"].ToString(); DTO_DownstageUsers dto_downstageusers = new DTO_DownstageUsers(); if (!IsPostBack) { try { if (code == "cmjjjc_ggl_nbtz") { if (Session["cmjjjc_downstageuser"] != null) { int downstageuserid = Convert.ToInt32(dao_downstageusers.GetDownstageUserIDByloginid(Session["cmjjjc_downstageuser"].ToString())); DataSet ds = _daocontent.GetDetailInfo(code, id); tdtitle.InnerHtml = ds.Tables[0].Rows[0]["title"].ToString(); subtitle.InnerHtml = ds.Tables[0].Rows[0]["subtitle"].ToString(); tdtime.InnerHtml = ds.Tables[0].Rows[0]["vdtime"].ToString(); tdcontent.InnerHtml = ds.Tables[0].Rows[0]["content"].ToString(); DataSet dsattach = _pubattach.GetAllPubattach(code, id); if (dsattach.Tables[0].Rows.Count > 0) { for (int i = 0; i < dsattach.Tables[0].Rows.Count; i++) { attachname.InnerHtml += "<a href='" + System.Configuration.ConfigurationManager.AppSettings["WebUrl"].ToString() + dsattach.Tables[0].Rows[i]["filepath"].ToString() + "' target='_parent'>" + dsattach.Tables[0].Rows[i]["filename"].ToString() + "</a><br/>"; } } else { attachname.Visible = false; } } else { Response.Write("<script>alert('您没权限访问,请先登录'); parent.location.href='http://www.baidu.com'</script>"); } } else { DataSet ds = _daocontent.GetDetailInfo(code, id); tdtitle.InnerHtml = ds.Tables[0].Rows[0]["title"].ToString(); subtitle.InnerHtml = ds.Tables[0].Rows[0]["subtitle"].ToString(); tdtime.InnerHtml = ds.Tables[0].Rows[0]["vdtime"].ToString(); tdcontent.InnerHtml = ds.Tables[0].Rows[0]["content"].ToString(); DataSet dsattach = _pubattach.GetAllPubattach(code, id); if (dsattach.Tables[0].Rows.Count > 0) { for (int i = 0; i < dsattach.Tables[0].Rows.Count; i++) { attachname.InnerHtml += "<a href='" + System.Configuration.ConfigurationManager.AppSettings["WebUrl"].ToString() + dsattach.Tables[0].Rows[i]["filepath"].ToString() + "' target='_parent'>" + dsattach.Tables[0].Rows[i]["filename"].ToString() + "</a><br/>"; } } else { attachname.Visible = false; } } } catch { Response.Write("<script>alert('页面加载错误,请跟管理员联系')</script>"); } } } } }