乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      asp.net 長內(nèi)容文章自動(dòng)分頁(精)

       悟靜 2012-09-19

      asp.net 長內(nèi)容文章自動(dòng)分頁

      前臺(tái)代碼:
      <%@ Page Language="C#" AutoEventWireup="true" CodeFile="articleview.aspx.cs" Inherits="articleview" %>
      <%@ Register Src="~/head.ascx" TagName="head" TagPrefix="uc1" %>
      <%@ Register Src="~/right.ascx" TagName="right" TagPrefix="uc2" %>
      <%@ Register Src="~/foot.ascx" TagName="foot" TagPrefix="uc3" %>

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www./TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www./1999/xhtml">
      <head>
      <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
      <title><%# strTitle %>-評(píng)選動(dòng)態(tài)-校園十大人物評(píng)選活動(dòng)-山東建筑大學(xué)法政學(xué)院</title>
      <link href="css.css" rel="stylesheet" type="text/css" />
      </head>
      <body>
      <form id="form1" runat="server">
          <div class="warper">
              <uc1:head ID="head" runat="server" />
              <div class="content">
                  <div class="left_cont">
                       <div class="daohang">當(dāng)前位置:<a href="default.aspx">首頁</a> >> <a href="dongtai.aspx"> 評(píng)選動(dòng)態(tài)</a> >> 正文</div>
                      <div class="pxdt third">
                          <div class="cont_title"> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label></div>
                          <div class="a_page f_color">文章發(fā)表時(shí)間:<span><asp:Label ID="Label2" runat="server" Text="Label"></asp:Label></span>  來源:<span><asp:Label ID="Label3" runat="server" Text="Label"></asp:Label></span></div>
                          <div class="body_cont">
                              <asp:Label ID="Label4" runat="server" Text="Label"></asp:Label>
                              <asp:Label ID="labPageNumber" Font-Size="14px" runat="server"> </asp:Label>
                          </div>
                      </div>
                  </div>
                  <uc2:right ID="right" runat="server" />
                  <div class="clear"></div>
              </div>
              <uc3:foot ID="foot" runat="server" />
              
          </div>
      </form>
      </body>
      </html>

      后臺(tái)代碼:
      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;

      public partial class articleview : System.Web.UI.Page
      {
          DbClass.DbAccesscontrol conn = new DbClass.DbAccesscontrol();
          public string strTitle = "";
          protected void Page_Load(object sender, EventArgs e)
          {
              if (!IsPostBack)
              {
                  string strid = Request.QueryString["id"].ToString();
                  int fid = 1;
                  try
                  {
                      fid = int.Parse(strid);
                  }
                  catch
                  { }

                  string strsql = "select * from YS_NewsInfo where id=" + fid;
                  DataTable dt = (DataTable)conn.gettable(strsql);
                  strTitle = dt.Rows[0]["title"].ToString();
                  Label1.Text = dt.Rows[0]["title"].ToString();
                  Label2.Text = dt.Rows[0]["datetime"].ToString();
                  Label3.Text = dt.Rows[0]["from"].ToString();
                  Label4.Text = OutputBySize(Server.HtmlDecode(dt.Rows[0]["info"].ToString()),fid);
                  DataBind();//必需嗎?

              }
          }

          //public string OutputArticle(string strcontent)
          //{
          //    string strid = Request.QueryString["id"].ToString();
          //    int fid = 1;
          //    try
          //    {
          //        fid = int.Parse(strid);
          //    }
          //    catch
          //    { }

          //    string strsql = "select * from YS_NewsInfo where id=" + fid;
          //    DataTable dt = (DataTable)conn.gettable(strsql);
          //    //strTitle = dt.Rows[0]["title"].ToString();
          //    //Label1.Text = dt.Rows[0]["title"].ToString();
          //    //Label2.Text = dt.Rows[0]["datetime"].ToString();
          //    //Label3.Text = dt.Rows[0]["from"].ToString();
          //    //Label4.Text = OutputBySize(Server.HtmlDecode(dt.Rows[0]["info"].ToString()));
          //    //DataBind();
          //    //return conn.NoHTML(Server.HtmlDecode(dt.Rows[0]["info"].ToString()));
          //    return Server.HtmlDecode(dt.Rows[0]["info"].ToString());
          //}

          public string OutputBySize(string p_strContent,int pageid)
          {
              string m_strRet = p_strContent;
              int m_intPageSize = 1000;//文章每頁大小
              int m_intCurrentPage = 1;//設(shè)置第一頁為初始頁
              int m_intTotalPage = 0;
              int m_intArticlelength = p_strContent.Length;//文章長度
              if (m_intPageSize < m_intArticlelength)
              {//如果每頁大小大于文章長度時(shí)就不用分頁了
                  if (m_intArticlelength % m_intPageSize == 0)
                  {//set total pages count
                      m_intTotalPage = m_intArticlelength / m_intPageSize;
                  }
                  else
                  {//if the totalsize
                      m_intTotalPage = m_intArticlelength / m_intPageSize + 1;
                  }
                  if (Request.QueryString["pages"] != null)
                  {//set Current page number
                      try
                      {//處理不正常的地址欄的值
                          m_intCurrentPage = Convert.ToInt32(Request.QueryString["pages"]);
                          if (m_intCurrentPage > m_intTotalPage)
                              m_intCurrentPage = m_intTotalPage;
                      }
                      catch
                      {
                          m_intCurrentPage = m_intCurrentPage;
                      }
                  }
                  //set the page content 設(shè)置獲取當(dāng)前頁的大小
                  m_intPageSize = m_intCurrentPage < m_intTotalPage ? m_intPageSize : (m_intArticlelength - m_intPageSize * (m_intCurrentPage - 1));
                  m_strRet = p_strContent.Substring(m_intPageSize * (m_intCurrentPage - 1), m_intPageSize);
                  string m_strPageInfo = "<p></p>";
                  for (int i = 1; i <= m_intTotalPage; i++)
                  {
                      if (i == m_intCurrentPage)
                          m_strPageInfo += "<b>" + i + "</b>|";
                      else
                          m_strPageInfo += "<a href=articleview.aspx?id=" + pageid + "&pages=" + i + ">" + i + "</a>|";
                  }
                  //輸出顯示各個(gè)頁碼
                  this.labPageNumber.Text = m_strPageInfo;
              }
              return m_strRet;
          }
      }

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請遵守用戶 評(píng)論公約