相应的C# cs文件,先引用using System.Text;其中的stringbuilder相对于string性能更好!
CS代码:
1 protected string contentBody;
2 protected string contentIssuedate;
3 protected string currentPage;
4 protected string allPage;
5
6 protected void Page_Load(object sender, EventArgs e)
7 {
8 BindContent();//提取内容
9 }
10 private void BindContent()
11 {
12 this.contentIssuedate = DateTime.Now.ToString();
13 // 用简单的数组代替正则表达式来进行相应的内容分组
14 string[] pages = new string[5] { "第<br>一<br>页<br>的<br>内<br>容", "第<br>二<br>页<br>的<br>内<br>容", "第<br>三<br>页<br>的<br>内<br>容", "第<br>四<br>页<br>的<br>内<br>容", "第<br>五<br>页<br>的<br>内<br>容" };
15 this.allPage = pages.Length.ToString();
16 this.currentPage ="1";
17 StringBuilder sb = new StringBuilder();
18 //设置所有的内容 进行JS的操作 display:none隐藏内容----
19 sb.Append("<div id=''currentPage'' style=''display: none;''>1</div>");
20 sb.Append("<div id=''allPage'' style=''display: none;''>" + pages.Length + "</div>");
21 for (int i = 0; i < pages.Length; i++)
22 {
23 int temp = i + 1;
24 if (i == 0)
25 {
26 sb.Append("<div id=''con_" + temp + "''>");
27& |