前面把cs代码全都贴得差不多了,现在也没有多少了
在那个moreAticle 又承继 Operator 类,这个类,就是一些常用的,如果反回首行首列值,返回所受影响的行数,返回一个DateSet,DataTable等等.下面是代码.
using
System;
using
System.Data;
using
System.Configuration;
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
XiaoTuNi.LHB_SQL_2005;
using
System.Data.SqlClient ;
![](https://i-blog.csdnimg.cn/blog_migrate/a41954a27d6ad96fa2c2cf816e677448.gif)
/**/
/// <summary>
/// Operator 操作基类
/// </summary>
public
class
Operator : basePage
![](https://i-blog.csdnimg.cn/blog_migrate/a41954a27d6ad96fa2c2cf816e677448.gif)
...
{
public Operator()
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
/**//// <summary>
/// 返回受影响的行数
/// </summary>
/// <param name="executeString">执行的Sql语句,或存储过程名</param>
/// <returns>true or false</returns>
protected static bool ExecuteNonQuery(string executeString)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
int count = GetCommand.ExecuteNonQuery(executeString);
if (count > 0)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
return true;
}
else
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
return false;
}
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
/**//// <summary>
/// 返回首行首列的值
/// </summary>
/// <param name="executeString">执行的Sql语句,或存储过程名</param>
/// <returns>true or false</returns>
protected static string ExecuteScalar(string executeString)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
string firstRow = GetCommand.ExecuteScalar(executeString);
return firstRow;
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
/**//// <summary>
/// 返回一个数据集
/// </summary>
/// <param name="executeString">执行的Sql语句,或存储过程名</param>
/// <returns>DataSet</returns>
protected static DataSet getDataSet(string execueString)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
DataSet ds = GetCommand.getDataSet(execueString);
return ds;
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
/**//// <summary>
/// 返回一个数据集
/// </summary>
/// <param name="executeString">执行的Sql语句,或存储过程名</param>
/// <param name="tableName">表的名称</param>
/// <returns>DataSet</returns>
protected static DataSet getDataSet(string executString, string tableName)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
DataSet ds = GetCommand.getDataSet(executString, tableName);
return ds;
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
/**//// <summary>
/// 返回一张表
/// </summary>
/// <param name="executeString">执行的Sql语句,或存储过程名</param>
/// <returns>DataTable</returns>
protected static DataTable getDataTable(string executeString)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
DataTable dt = GetCommand.getDataTable(executeString);
return dt;
}
![](https://i-blog.csdnimg.cn/blog_migrate/6a9c071a08f1dae2d3e1c512000eef41.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
/**//// <summary>
/// 返回一个只读对象
/// </summary>
/// <param name="executeString">执行的Sql语句,或存储过程名</param>
/// <returns>SqlDataReader</returns>
protected static SqlDataReader ExecuteReader(string executeString)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
SqlDataReader sdr = GetCommand.ExecuteReader(executeString); //可能以后这里会出问题
return sdr;
}
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
/**//// <summary>
/// 获取主机MAC地址
/// </summary>
protected static string getComputeMACAddress
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
get ...{ return getComputeInformation.getComputeMAC; }
}
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
/**//// <summary>
/// 获取主机的IP地址
/// </summary>
protected static string getComputeIpAddress
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
get ...{ return getComputeInformation.getComputeIpAddress; }
}
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
/**//// <summary>
/// 获取主机名
/// </summary>
protected static string getComputeHostName
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
get ...{ return getComputeInformation.getComputeHostName; }
}
}
这个类是我的blog中用得相当平凡的一个类,添加删除修改等操作
都承继它.好了现在差不多了,就只差javascript代码了
//
JScript 文件
var taxisStatue
=
1
;
var articlePageCount
=
0
;
var numberValue
=
0
;
function OnLoad_moreArticle()
![](https://i-blog.csdnimg.cn/blog_migrate/a41954a27d6ad96fa2c2cf816e677448.gif)
...
{
articlePageCount = Blog_moreArticle.getPageCount().value;
Blog_moreArticle.article(_doPostArticleDate);
}
function _doPostArticleDate(res)
![](https://i-blog.csdnimg.cn/blog_migrate/a41954a27d6ad96fa2c2cf816e677448.gif)
...
{
try
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
var allContent = res.value.split("|||");
var articleId = allContent[0].split("//");
var blogName = allContent[1].split("//");
var userName = allContent[2].split("//");
var title = allContent[3].split("//");
var issueTime = allContent[4].split("//");
var max = title.length - 1;
var info = "";
var middleValue = 0;
var bbb = "";
for(var i = 0 ; i < max ; i++)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
info +='<tr><td><a href="MyBlog.aspx?BlogName='+ userName[i] + '" target="_blank" >[' + blogName[i] + ']</a></td><td> - <a href="MyBlog.aspx?BlogName='+ userName[i] + '" target="_blank" >' + userName[i] + '</a></td><td> - <a href="Reversion.aspx?Number=' + articleId[i] + '" target="_blank" >' + title[i] + ' </a></td><td> - <a href="javascript:void()">' + issueTime[i] + '</td></a></tr>'
}
info = '<table><tr><td><a href="javascript:_blogName()"> blog名 </a></td><td><a href="javascript:_userName()"> 用户名 </a></td><td><a href="javascript:_title()"> 标题 </a></td><td><a href="javascript:_issueTime()"> 时间 </a></td>' + info + '</table>';
if(articlePageCount > 10) // 当页数大于10时,就显示出前十页.
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
if( numberValue > 5 && numberValue < articlePageCount-5) //当点击的值在 5 <number< max - 5 之间时
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
middleValue = numberValue - 5;
for(var i = 1 + middleValue ; i <= 10 + middleValue ; i++)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
bbb +='<td><a href="javascript:pageNumber('+ i + ')">' + i + '</a></td>';
}
}
else if(numberValue >= articlePageCount-5) //当点的页数在 number >= max - 5 时进入下面代码
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
for(var i = articlePageCount - 9 ; i <= articlePageCount ; i++)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
bbb +='<td><a href="javascript:pageNumber('+ i + ')">' + i + '</a></td>';
}
}
else //当点击的值在10以内就执行下面代码
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
for(var i = 1; i <= 10 ; i++)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
bbb +='<td><a href="javascript:pageNumber('+ i + ')">' + i + '</a></td>';
}
}
}
else //总页数小10的话就执行下面代码
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
for(var i = 1; i <= articlePageCount ; i++)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
bbb +='<td><a href="javascript:pageNumber('+ i + ')">' + i + '</a></td>';
}
}
bbb = '<table>' + bbb + '</table>';
document.getElementById("allArticle").innerHTML = info + bbb ;
}
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
catch(e)...{}
}
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
function pageNumber(number)
![](https://i-blog.csdnimg.cn/blog_migrate/a41954a27d6ad96fa2c2cf816e677448.gif)
...
{
numberValue = number ;
Blog_moreArticle.setArticlePageCount(number);
Blog_moreArticle.article(_doPostArticleDate);
}
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
function _issueTime()
![](https://i-blog.csdnimg.cn/blog_migrate/a41954a27d6ad96fa2c2cf816e677448.gif)
...
{
if(taxisStatue == 1)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
taxisStatue = 2;
}
else
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
taxisStatue = 1;
}
Blog_moreArticle.article_issueTime(taxisStatue,_doPostArticleDate);
}
function _title()
![](https://i-blog.csdnimg.cn/blog_migrate/a41954a27d6ad96fa2c2cf816e677448.gif)
...
{
if(taxisStatue == 1)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
taxisStatue = 2;
}
else
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
taxisStatue = 1;
}
Blog_moreArticle.artitle_title(taxisStatue,_doPostArticleDate);
}
function _userName()
![](https://i-blog.csdnimg.cn/blog_migrate/a41954a27d6ad96fa2c2cf816e677448.gif)
...
{
if(taxisStatue == 1)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
taxisStatue = 2;
}
else
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
taxisStatue = 1;
}
Blog_moreArticle.article_userName(taxisStatue,_doPostArticleDate);
}
function _blogName()
![](https://i-blog.csdnimg.cn/blog_migrate/a41954a27d6ad96fa2c2cf816e677448.gif)
...
{
if(taxisStatue == 1)
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
taxisStatue = 2;
}
else
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
taxisStatue = 1;
}
Blog_moreArticle.artitle_blogName(taxisStatue,_doPostArticleDate);
}
在这个javascript代码当中我没有对其异常处理
还有前面cs也是我也都没有做很好的处理
只是实现了,大家可以跟自己的要求,多加异常处理操作以减少错误次数.
下面就是Web的html代码了.这里有两个用户自定义控件,一个菜单,一个CopyRight了.
<%
...
@ Page Language="C#" AutoEventWireup="true" CodeFile="moreArticle.aspx.cs" Inherits="Blog_moreArticle"
%>
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/a41954a27d6ad96fa2c2cf816e677448.gif)
<%
...
@ Register Src="../userControl/blogMenu.ascx" TagName="blogMenu" TagPrefix="uc1"
%>
![](https://i-blog.csdnimg.cn/blog_migrate/a41954a27d6ad96fa2c2cf816e677448.gif)
<%
...
@ Register Src="../userControl/CopyRight.ascx" TagName="CopyRight" TagPrefix="uc2"
%>
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
<!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
>
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
<
html
xmlns
="http://www.w3.org/1999/xhtml"
>
<
head
runat
="server"
>
<
title
>
所有文章
</
title
>
<
link
href
="../CSS/blog.css"
rel
="stylesheet"
type
="text/css"
/>
<
script
type
="text/javascript"
src
="../JavaScript/moreArticle.js"
></
script
>
</
head
>
<
body
onload
="OnLoad_moreArticle()"
;
>
<
form
id
="form1"
runat
="server"
>
<
div
>
<
table
>
<
tr
>
<
td
>
<
div
>
<
uc1:blogMenu
ID
="BlogMenu1"
runat
="server"
/>
</
div
>
</
td
>
</
tr
>
<
tr
>
<
td
>
<
div
>
<
table
>
<
tr
valign
="top"
>
<
td
>
<
div
>
</
div
>
</
td
>
<
td
>
<
div
>
<
asp:Panel
ID
="panel1_allShowArticle"
runat
="server"
GroupingText
="所有文章"
>
<
div
class
="allArticle"
id
="allArticle"
>
</
div
>
</
asp:Panel
>
</
div
>
</
td
>
<
td
>
<
div
>
</
div
>
</
td
>
</
tr
>
</
table
>
</
div
>
</
td
>
</
tr
>
<
tr
>
<
td
>
<
div
>
<
uc2:CopyRight
ID
="CopyRight1"
runat
="server"
/>
</
div
>
</
td
>
</
tr
>
</
table
>
</
div
>
</
form
>
</
body
>
</
html
>
好了以上代码就是我实现像前部分图中所实现的分页了.