易截截图软件、单文件、免安装、纯绿色、仅160KB

Paging long articles in ASP.NET using C#

Paging long articles in ASP.NET using C#
Long articles are better broken into bite-sized chunks over several pages. With static HTML, this is easily achieved by dividing the article into logical separations and creating separate .htm files for each. Here's how to do it using C# for an article that gets posted to a database.
The Regular Expression Split() method returns a one-dimensional zero-based array containing a number of substrings, so it is perfect for this job. What I want to do is take an article (which is a string) and divide it into substrings. In order to do this, I need a delimiter, and I use <!--pagebreak-->. As I enter the article into the database, I place <!--pagebreak--> at the points I want to break the article.
Then, having extracted the article from the database, I pass it to the following static method which I have in a utility class:
public static string PageArticle(string Article)
{
string Output;
string ThisPage = HttpContext.Current.Request.ServerVariables["SCRIPT_NAME"];

string PageNo;
PageNo = HttpContext.Current.Request.QueryString["Page"];
if (Article.IndexOf("<!--pagebreak-->") != -1)
{
string[] Pages = Regex.Split(Article, "<!--pagebreak-->");
int TotalPages = Pages.GetUpperBound(0) + 1;
int Counter = 1;
int PageNumber = 1;
if (PageNo != null)
{
PageNumber = System.Convert.ToInt32(PageNo);
}
Output = Pages[PageNumber - 1];
Output += "<p>Go to Page ";
while (Counter <= TotalPages)
{
if (Counter == PageNumber)
{
Output += Counter.ToString() + " ";
}
else
{
Output += "<a href="\" mce_href="\""" + ThisPage + "?Page=" + Counter.ToString();
Output += "\">" + Counter.ToString() + "</a> ";
}
Counter++;
}
Output += "</p>";
}
else
{
Output = Article;
}
re


相关文档:

C#(ASP.NET) 下载数据

Internet 类
using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;
using System.Net;
using System.IO;
using System.Text.RegularExpressions;
using System.Threading;
namespace DownData
{
    class internet
    {
 &nb ......

WCF中的服务和ASP.NET AJAX中的WebService

WCF的架构:using System.ServiceModel;
契约:Contract
[ServiceContract]
public partial interface IContract
{
        [OperationContract]
        string DocumentWebHostUrl();
}
服务:Service
[ServiceBehavior(IncludeException ......

转:ASP.NET页面传值的几种方式

一. 使用QueryString变量
    QueryString是一种非常简单也是使用比较多的一种传值方式,但是它将传递的值显示在浏览器的地址栏中,如果是传递一个或多个安全性要求不高或是结构简单的数值时,可以使用这个方法。
         Response.Redirect( "target.aspx?param1=hello& ......

asp.net 中实现页面每隔一分钟刷新一次的效果

在Global.asax
需要回顾的知识点是 线程 和  文本文件的读写。
<%@ Application Language="C#" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Threading" %>
<script runat="server">
    string logpath;
    Thread thread; ......

ASP.NET页面刷新方法总结

先看看ASP.NET页面刷新的实现方法:
第一:
C# code
private void Button1_Click( object sender, System.EventArgs e )
{
Response.Redirect( Request.Url.ToString( ) );
}
第二:
C# code
private void Button2_Click( object sender, System.EventArgs e )
{
Response.Write( " < script lang ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号