📄 index.aspx
字号:
<%@ Page Language="C#" ContentType="text/html"%>
<%@ Import Namespace="hxt" %>
<%@ Import Namespace="System.Data" %>
<script runat="server">
mydbclass mydb=null;
int inttotalnumber;
int inttotalpage;
int startnumber;
protected void Page_Load(Object Src, EventArgs E)
{
mydb=new mydbclass();
inttotalnumber=mydb.gettotalnumber();
inttotalpage=mydb.gettotalpage(inttotalnumber);
if (!IsPostBack)
{
pagebind(1);
}
}
void pagebind(int currentpage)
{
startnumber=(currentpage-1)*int.Parse(ConfigurationSettings.AppSettings["每页显示条数"])+1;
ArrayList al=new ArrayList();
for(int j=1;j<=inttotalpage;j++)
{al.Add(j);}
gopage.DataSource=al;
gopage.DataBind();
gopage.SelectedIndex=currentpage-1;
bool iffirst=(currentpage<=1);
if(iffirst) currentpage=1;
bool iflast=(currentpage>=inttotalpage);
if(iflast) currentpage=inttotalpage;
DataTable dt=mydb.getcurrentpagedata(currentpage);
myrepeater.DataSource=dt.DefaultView;
myrepeater.DataBind();
totalnumber.Text=inttotalnumber.ToString();
currentpagenumber.Text=currentpage.ToString();
totalpage.Text=inttotalpage.ToString();
pagesize.Text=ConfigurationSettings.AppSettings["每页显示条数"];
prebutton.ImageUrl=iffirst?"images/up0.gif":"images/up.gif";
prebutton.Enabled=!iffirst;
firstbutton.Enabled=!iffirst;
nextbutton.ImageUrl=iflast?"images/down0.gif":"images/down.gif";
nextbutton.Enabled=!iflast;
lastbutton.Enabled=!iflast;
}
void firstlast(object o,CommandEventArgs e)
{
if(e.CommandName=="firstbutton")
pagebind(1);
else
pagebind(inttotalpage);
}
void prenext(object o,CommandEventArgs e)
{
if(e.CommandName=="prebutton")
pagebind(Int32.Parse(currentpagenumber.Text)-1);
else
pagebind(Int32.Parse(currentpagenumber.Text)+1);
}
void gotopage(object o,EventArgs e)
{
pagebind(gopage.SelectedIndex+1);
}
string ubb(string srcstring)
{
string objstring;
Regex myrg=null;
myrg=new Regex(@"\[img\](?<path>.+?)\[/img\]");
objstring=myrg.Replace(srcstring,"<br><img src='${path}'><br>");
myrg=new Regex(@"\[url\](http://.+?)\[/url\]");
objstring=myrg.Replace(srcstring,"<a href='${1}' target=_blank>${1}</a>");
return objstring;
}
</script>
<!--#include file="top.aspx"-->
<form runat="server">
<table width="790" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center" class="style1">所有留言</td>
</tr>
</table>
<asp:Repeater EnableViewState="false" ID="myrepeater" runat="server">
<itemtemplate>
<table width="790" border="0" align="center" cellpadding="0" cellspacing="0" id="solidtable">
<tr>
<td width="129" rowspan="4" align="center" valign="middle">NO.<%# startnumber++ %><br>
<img name="" src="<%# DataBinder.Eval(Container.DataItem,"touxiang","images/face/{0}.gif") %>" width="32" height="32" alt=""><br>
<%# "<b>"+Server.HtmlEncode(DataBinder.Eval(Container.DataItem,"nicheng","{0}"))+"</b>" %></td>
<td width="473"><img src="images/subject.gif" width="13" height="13"><%# Server.HtmlEncode(DataBinder.Eval(Container.DataItem,"biaoti","{0}")) %></td>
<td width="187" nowrap><img src="images/posttime.gif" width="16" height="15"><%# DataBinder.Eval(Container.DataItem,"shijian") %></td>
</tr>
<tr>
<td height="59" colspan="2" valign="top"><%# ubb(Server.HtmlEncode(DataBinder.Eval(Container.DataItem,"liuyan","{0}")).Replace("\n","<br>").Replace(" "," ")) %></td>
</tr>
<tr>
<td height="47" colspan="2" valign="top">回复:<%# DataBinder.Eval(Container.DataItem,"huifu") %></td>
</tr>
<tr>
<td colspan="2" align="right"><img src="images/ip.gif" width="52" height="16" title="<%# DataBinder.Eval(Container.DataItem,"ip","IP:{0}") %>"><img src="images/email.gif" width="45" height="18"><img src="images/oicq.gif" width="45" height="18"><img src="images/home.gif" width="44" height="16"><img src="images/reply_a.gif" width="45" height="18"><a href="<%# DataBinder.Eval(Container.DataItem,"bianhao","admin/delete.aspx?id={0}") %>"><img src="images/delete.gif" width="18" height="18" border=0></a></td>
</tr>
</table>
<br>
</itemtemplate>
</asp:Repeater>
<table width="790" id="solidtable" height="32" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="31" align="center">共有<asp:Label EnableViewState="false" ID="totalnumber" runat="server" />
条留言 当前第<asp:Label ID="currentpagenumber" runat="server" />/<asp:Label EnableViewState="false" ID="totalpage" runat="server" />
页 每页显示<asp:Label EnableViewState="false" ID="pagesize" runat="server" />
条 <asp:LinkButton CommandName="firstbutton" EnableViewState="false" ID="firstbutton" runat="server" Text="首页" OnCommand="firstlast">首页</asp:LinkButton>
<asp:ImageButton CommandName="prebutton" EnableViewState="false" ID="prebutton" runat="server" OnCommand="prenext" /><asp:ImageButton CommandName="nextbutton" EnableViewState="false" ID="nextbutton" runat="server" OnCommand="prenext" />
<asp:LinkButton CommandName="lastbutton" EnableViewState="false" ID="lastbutton" runat="server" Text="尾页" OnCommand="firstlast"></asp:LinkButton>
转到
<asp:DropDownList AutoPostBack="true" ID="gopage" runat="server" OnSelectedIndexChanged="gotopage"></asp:DropDownList>
页 </td>
</tr>
</table>
</form>
<!--#include file="bottom.aspx"-->
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -