首先,建立一个模板也,即:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="web.Manage.Index" %>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<title>网站管理系统</title>
<link href="/themes/default/style.css" rel="stylesheet" type="text/css" media="screen" />
<link href="/themes/css/core.css" rel="stylesheet" type="text/css" media="screen" />
<link href="/themes/css/print.css" rel="stylesheet" type="text/css" media="print" />
<link href="/uploadify/css/uploadify.css" rel="stylesheet" type="text/css" media="screen" />
<!--[if IE]>
<link href="themes/css/ieHack.css" rel="stylesheet" type="text/css" media="screen"/>
<![endif]-->
<script src="/js/speedup.js" type="text/javascript"></script>
<script src="/js/jquery-1.7.2.js" type="text/javascript"></script>
<script src="/js/jquery.cookie.js" type="text/javascript"></script>
<script src="/js/jquery.validate.js" type="text/javascript"></script>
<script src="/js/jquery.bgiframe.js" type="text/javascript"></script>
<script src="/xheditor/xheditor-1.1.14-zh-cn.min.js" type="text/javascript"></script>
<%-- <script src="/uploadify/scripts/swfobject.js" type="text/javascript"></script>
<script src="/uploadify/scripts/jquery.uploadify.v2.1.0.js" type="text/javascript"></script>--%>
<!-- svg图表 supports Firefox 3.0+, Safari 3.0+, Chrome 5.0+, Opera 9.5+ and Internet Explorer 6.0+ -->
<script type="/text/javascript" src="../chart/raphael.js"></script>
<script type="/text/javascript" src="../chart/g.raphael.js"></script>
<script type="/text/javascript" src="../chart/g.bar.js"></script>
<script type="/text/javascript" src="../chart/g.line.js"></script>
<script type="/text/javascript" src="../chart/g.pie.js"></script>
<script type="/text/javascript" src="../chart/g.dot.js"></script>
<script src="/js/dwz.core.js" type="text/javascript"></script>
<script src="/js/dwz.util.date.js" type="text/javascript"></script>
<script src="/js/dwz.validate.method.js" type="text/javascript"></script>
<script src="/js/dwz.regional.zh.js" type="text/javascript"></script>
<script src="/js/dwz.barDrag.js" type="text/javascript"></script>
<script src="/js/dwz.drag.js" type="text/javascript"></script>
<script src="/js/dwz.tree.js" type="text/javascript"></script>
<script src="/js/dwz.accordion.js" type="text/javascript"></script>
<script src="/js/dwz.ui.js" type="text/javascript"></script>
<script src="/js/dwz.theme.js" type="text/javascript"></script>
<script src="/js/dwz.switchEnv.js" type="text/javascript"></script>
<script src="/js/dwz.alertMsg.js" type="text/javascript"></script>
<script src="/js/dwz.contextmenu.js" type="text/javascript"></script>
<script src="/js/dwz.navTab.js" type="text/javascript"></script>
<script src="/js/dwz.tab.js" type="text/javascript"></script>
<script src="/js/dwz.resize.js" type="text/javascript"></script>
<script src="/js/dwz.dialog.js" type="text/javascript"></script>
<script src="/js/dwz.dialogDrag.js" type="text/javascript"></script>
<script src="/js/dwz.sortDrag.js" type="text/javascript"></script>
<script src="/js/dwz.cssTable.js" type="text/javascript"></script>
<script src="/js/dwz.stable.js" type="text/javascript"></script>
<script src="/js/dwz.taskBar.js" type="text/javascript"></script>
<script src="/js/dwz.ajax.js" type="text/javascript"></script>
<script src="/js/dwz.pagination.js" type="text/javascript"></script>
<script src="/js/dwz.database.js" type="text/javascript"></script>
<script src="/js/dwz.datepicker.js" type="text/javascript"></script>
<script src="/js/dwz.effects.js" type="text/javascript"></script>
<script src="/js/dwz.panel.js" type="text/javascript"></script>
<script src="/js/dwz.checkbox.js" type="text/javascript"></script>
<script src="/js/dwz.history.js" type="text/javascript"></script>
<script src="/js/dwz.combox.js" type="text/javascript"></script>
<script src="/js/dwz.print.js" type="text/javascript"></script>
<script src="/js/uploadify/jquery.uploadify.min.js" type="text/javascript"></script>
<link href="/js/uploadify/uploadify.css" rel="stylesheet" type="text/css" />
<script src="/js/uploadify/jquery.uploadify.min.js" type="text/javascript"></script>
<!--
<script src="bin/dwz.min.js" type="text/javascript"></script>
-->
<script src="/js/dwz.regional.zh.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
DWZ.init("/dwz.frag.xml", {
//loginUrl: "/login_dialog.html", loginTitle: "登录", // 弹出登录对话框
loginUrl: "login.html", // 跳到登录页面
statusCode: { ok: 200, error: 300, timeout: 301 }, //【可选】
pageInfo: { pageNum: "pageNum", numPerPage: "numPerPage", orderField: "orderField", orderDirection: "orderDirection" }, //【可选】
debug: false, // 调试模式 【true|false】
callback: function () {
initEnv();
$("#themeList").theme({ themeBase: "/themes" }); // themeBase 相对于index页面的主题base路径
}
});
});
function iframeResizeHeight(frame_name, body_name, offset) {
alert(document.getElementById(body_name).offsetHeight);
parent.document.getElementById(frame_name).height = document.getElementById(body_name).offsetHeight + offset;
}
function Resize() {
var frame_name = "main_info";
var body_name = "div_main";
if (parent.document.getElementById(frame_name)) {
return iframeResizeHeight(frame_name, body_name, 0);
}
}
</script>
</head>
<body scroll="no">
<div id="layout">
<div id="header">
<div class="headerNav">
<a class="logo">标志</a>
<ul class="nav">
<li><a href="main.aspx" target="navTab" rel="main">我的主页</a></li>
<li><a href="SystemInfo/ModifyPWD.aspx" target="dialog">修改密码</a></li>
<li><a href="../login.aspx">退出</a></li>
</ul>
<ul class="themeList" id="themeList">
<li theme="default">
<div class="selected">
蓝色</div>
</li>
<li theme="green">
<div>
绿色</div>
</li>
<li theme="purple">
<div>
紫色</div>
</li>
<li theme="silver">
<div>
银色</div>
</li>
<li theme="azure">
<div>
天蓝</div>
</li>
</ul>
</div>
<!-- navMenu -->
</div>
<div id="leftside">
<div id="sidebar_s">
<div class="collapse">
<div class="toggleCollapse">
<div>
</div>
</div>
</div>
</div>
<div id="sidebar">
<div class="toggleCollapse">
<h2>
主菜单</h2>
<div>
收缩</div>
</div>
<div class="accordion" fillspace="sidebar">
<div class="accordionHeader">
<h2>
<span>Folder</span>菜单</h2>
</div>
<div class="accordionContent">
<ul class="tree treeFolder">
<li><a>菜单1</a>
<ul>
<li><a href="ceshi.aspx" target="navTab" rel="1">1</a></li>
<li><a href="liuyanban.aspx" target="navTab" rel="2">2</a></li>
<li><a href="CSS Table.aspx" target="navTab" rel="3">3</a></li>
<li><a href="adddeleditlook.aspx" target="navTab" rel="4">4</a></li>
<li><a href="Complete/ManageResult.aspx" target="navTab" rel="5">5</a></li>
<li><a href="HuiKuan/LendHuiKuan.aspx" target="navTab" rel="6">6</a></li>
</ul>
</li>
<li><a>菜单2</a>
<ul>
<li><a href="upload.aspx" target="dialog" rel="7">上传</a></li>
</ul>
</li>
<li><a href="Search/SouSuo.aspx" target="navTab" rel="9">菜单3</a></li>
</ul>
</div>
<div class="accordionHeader">
<h2>
<span>Folder</span>管理</h2>
</div>
<div class="accordionContent">
<ul class="tree treeFolder">
<li><a>管理1</a>
<ul>
<li><a href="Sales/SellList.aspx" target="navTab" rel="19">45</a></li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</div>
<div id="container">
<div id="navTab" class="tabsPage">
<div class="tabsPageHeader">
<div class="tabsPageHeaderContent">
<ul class="navTab-tab">
<li tabid="main" class="main"><a href="javascript:;"><span><span class="home_icon">我的主页</span></span></a></li>
</ul>
</div>
<div class="tabsLeft">
left</div>
<div class="tabsRight">
right</div>
<div class="tabsMore">
more</div>
</div>
<ul class="tabsMoreList">
<li><a href="javascript:;">我的主页</a></li>
</ul>
<div class="navTab-panel tabsPageContent layoutBox" id="div_main">
<div class="page unitBox">
<iframe src="Main.aspx" id="main_info" οnlοad="this.height=0;var fdh=(this.Document?this.Document.body.scrollHeight:this.contentDocument.body.offsetHeight);this.height=(fdh>500?fdh:500);"
width="100%" frameborder="0" scrolling="auto" noresize />
</div>
</div>
</div>
</div>
</div>
<div id="footer">
Copyright © 2010 AOSY 魏魏
</div>
</body>
</html>
然后,实现一个页面的怎删改查搜索分页功能,即:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="adddeleditlook.aspx.cs"
Inherits="web.Manage.adddeleditlook" %>
<%@ Import Namespace="Extension" %>
<!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>
</head>
<body>
<form id="pagerForm" method="post" action="adddeleditlook.aspx?act=search">
<input type="hidden" name="pageNum" value="1" />
<input type="hidden" name="numPerPage" value="<%=NumPerPage %>" />
<input type="hidden" name="orderField" value="<%=OrderField %>" />
<input type="hidden" name="orderDirection" value="<%=OrderDirection %>" />
<input type="hidden" name="name" value="<%=name %>" />
<input type="hidden" name="addtime" value="<%=addtime %>" />
<input type="hidden" name="addtime2" value="<%=addtime2 %>" />
</form>
<div class="pageHeader">
<form οnsubmit="return navTabSearch(this);" action="adddeleditlook.aspx?act=search"
method="post">
<div class="searchBar">
<div class="subBar">
<ul style="float: left; margin-top: 5px">
<li>姓 名:<input type="text" name="Name"
value="<%=name %>" /></li>
<li>留言日期:<input type="text" style="width: 127px" name="addtime" datefmt="yyyy-MM-dd"
size="30" class="required date" value="<%=addtime %>" />
—
<input type="text" style="width: 127px" name="addtime2" datefmt="yyyy-MM-dd" size="30"
class="required date" value="<%=addtime2 %>" />
<%-- <a href="javascript:void(0);" class="inputDateButton">选择</a>--%></li>
<li style="margin-top: 10px;">
<div class="buttonActive">
<div class="buttonContent">
<button type="submit">
检索
</button>
</div>
</div>
</li>
</ul>
</div>
</div>
</form>
</div>
<div class="pageContent">
<div class="panelBar">
<ul class="toolBar">
<li><a class="edit" id="rr"><span>刷新</span></a></li>
<li class="line">line</li>
<li><a class="delete" href="ZhaiQ/AddNewZQ.ashx?Action=mdel" target="selectedTodo"
rel="ids" posttype="string" title="确定要这些删除吗?"><span>批量删除</span></a></li>
</ul>
</div>
<table class="table" width="100%" layouth="127" nowraptd="false">
<thead align="center">
<tr align="center">
<th width="22">
<input type="checkbox" group="ids" class="checkboxCtrl">
</th>
<th>
姓名
</th>
<th>
留言
</th>
<th>
添加时间
</th>
<th>
头像
</th>
<th>
操作
</th>
</tr>
</thead>
<tbody align="center">
<asp:Repeater ID="xinxi" runat="server">
<ItemTemplate>
<tr target="sid_user" rel="<%#Eval("id")%>" align="center">
<td>
<input name="ids" value='<%#Eval("id")%>' type="checkbox">
</td>
<td>
<%#Eval("name")%>
</td>
<td>
<%#Eval("liuyan")%>
</td>
<td>
<%#Eval("addtime")%>
</td>
<td>
<img src='<%#Eval("img")%>' width="100px" height="100px" />
</td>
<td>
<a title="编辑" target="dialog" width="400" height="500" href="ZhaiQ/EditZQ.aspx?id=<%#Eval("id")%>"
style="color: Blue">
<img src="/themes/default/images/button/edit.gif" style="vertical-align: middle;
width: 15px; height: 15px;" alt="编辑" /> 编辑</a> <a title="确定要删除吗?" target="ajaxTodo"
style="color: Blue" href="ZhaiQ/AddNewZQ.ashx?Action=del&id=<%#Eval("id")%>">
<img src="/themes/default/images/button/del.gif" style="vertical-align: middle; width: 15px;
height: 15px;" alt="删除" /> <span>删除</span></a>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</tbody>
</table>
<div class="panelBar">
<div class="pages">
<span>显示</span>
<select class="combox" name="numPerPage" οnchange="navTabPageBreak({numPerPage:this.value})"
param="numPerPage">
<option value="<%=NumPerPage%>">选择</option>
<option value="10">10</option>
<option value="20">20</option>
<option value="30">30</option>
<option value="50">50</option>
<option value="100">100</option>
</select>
<span>条,共<%=TotalCount %>条</span>
</div>
<div class="pagination" targettype="navTab" totalcount="<%=TotalCount %>" numperpage="<%=NumPerPage %>"
pagenumshown="<%=PageNumShown %>" currentpage="<%=PageNum %>">
</div>
</div>
</div>
</body>
</html>
后台:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Extension;
using System.Data;
namespace web.Manage
{
public partial class adddeleditlook : BasePage
{
public string name;
public string addtime;
public string addtime2;
BLL.liuyanban bll = new BLL.liuyanban();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Bind();
}
}
public void Bind()
{
string strWhere = " 1=1 ";
if (Request.Form["name"] != null && Request.Form["name"] != "")
{
name = Request.Form["name"];
strWhere += " and name like '%" + name + "%' ";
}
if (Request.Form["addtime"] != null && Request.Form["addtime"] != "")
{
addtime = Request.Form["addtime"];
strWhere += " and addtime >='" + addtime + " 00:00:00' ";
}
if (Request.Form["addtime2"] != null && Request.Form["addtime2"] != "")
{
addtime2 = Request.Form["addtime2"];
strWhere += " and addtime <='" + addtime2 + " 00:00:00' ";
}
//strWhere += " order by addtime desc ";
keystring = strWhere;
DataSet ds = bll.GetData("*", strWhere, (pageNum - 1) * numPerPage, NumPerPage, out totalCount);
if (ds != null)
{
xinxi.DataSource = ds.Tables[0];
xinxi.DataBind();
}
}
}
}
/// <summary>
/// 获取数据[用于分页]
/// </summary>
/// <param name="Fields">字段字符串[全部为*]</param>
/// <param name="Wheres">条件[可为空]</param>
/// <param name="StartIndex">开始记录数</param>
/// <param name="PageSize">每页显示记录数</param>
/// <param name="RecordCount">记录总数</param>
public DataSet GetData(string Fields, string Wheres, int StartIndex, int PageSize, out int RecordCount)
{
int count = 0;
DataSet ds = dal.GetData(Fields, Wheres, StartIndex, PageSize, out count);
RecordCount = count;
return ds;
}
/// <summary>
/// 获取数据[用于分页]
/// </summary>
/// <param name="Fields">字段字符串[全部为*]</param>
/// <param name="Wheres">条件[可为空]</param>
/// <param name="StartIndex">开始记录数</param>
/// <param name="PageSize">每页显示记录数</param>
/// <param name="RecordCount">记录总数</param>
public DataSet GetData(string Fields, string Wheres, int StartIndex, int PageSize, out int RecordCount)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("Select " + Fields + " From LY_liuyanban ");
if (Wheres.Length > 0)
{
strSql.Append("Where " + Wheres + " order by addtime desc ");
}
else
{
strSql.Append(" order by addtime desc ");
}
StringBuilder countSql = new StringBuilder();
countSql.Append("Select Count(*) From LY_liuyanban ");
if (Wheres.Length > 0 && Wheres.ToLower().IndexOf("order by") > -1)
{
//去除后面的Order by语句
Wheres = Wheres.Substring(0, Wheres.Length - (Wheres.Length - Wheres.ToLower().IndexOf("order by")));
countSql.Append("Where " + Wheres + "");
}
else
{
countSql.Append("Where " + Wheres + "");
}
int count = 0;
DataSet ds = AosySql.ExecuteforDataSet(StartIndex, PageSize, out count, strSql.ToString(), countSql.ToString());
RecordCount = count;
return ds;
}