ASP.net文章管理系统:系统设计与编码。
14.3.4 ArticlesList.aspx的设计与编码
ArticlesList.aspx提供了两个功能:
(1)根据传入参数列出该类别的文章列表;
(2)根据传入参赛检索出符合条件的文章列表。
这两个功能的实现是有后台逻辑程序根据传入的参数类型判断,然后为用户提供不同的服务。
ArticlesList.aspx的HTML代码如下:
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="ArticlesList.aspx.vb" Inherits="TheArticleSYS.ArticlesList"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<meta name="vs_snapToGrid" content="False">
<title>ArticlesList</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<center>
<TABLE id="Table1" style="BORDER-RIGHT: #009999 1px solid; BORDER-TOP: #009999 1px solid; BORDER-LEFT: #009999 1px solid; BORDER-BOTTOM: #009999 1px solid"
cellSpacing="0" cellPadding="0" width="760" border="1">
<TR>
<TD><IMG src="images/bg12.jpg"></TD>
</TR>
<TR>
<TD><FONT face="宋体"></FONT></TD>
</TR>
<TR>
<TD>
<TABLE id="Table2" style="BORDER-RIGHT: #006600 1pt solid; BORDER-TOP: #006600 1pt solid; BORDER-LEFT: #006600 1pt solid; BORDER-BOTTOM: #006600 1pt solid"
cellSpacing="0" cellPadding="0" width="762" border="0">
<asp:datalist id="DataList1" runat="server" BorderColor="#009999" BorderWidth="1pt">
<AlternatingItemStyle BackColor="Azure"></AlternatingItemStyle>
<HeaderStyle Font-Size="Larger" Font-Bold="True" ForeColor="Azure" BackColor="#009999"></HeaderStyle>
<ItemTemplate>
<tr>
<TD align="left" style="FONT-WEIGHT: bold; FONT-SIZE: 12pt; BACKGROUND-COLOR: darkgray">标题:
<a href='<%# "TheArticle.aspx?aid="&databinder.eval(container.dataitem,"id") %>' target=_blank >
<%# databinder.eval(container.dataitem,"title") %>
</a>
</TD>
</tr>
<tr>
<TD align="left" style="FONT-SIZE: 11pt; BACKGROUND-COLOR: lightgrey">
id:<%# databinder.eval(container.dataitem,"id") %>
作者:<%# databinder.eval(container.dataitem,"writer") %>
---发布日期:<%# databinder.eval(container.dataitem,"sdate") %>
---浏览次数:<%# databinder.eval(container.dataitem,"views") %>
</TD>
</tr>
<tr>
<TD align="left" style="FONT-SIZE: 11pt; BACKGROUND-COLOR: lightgrey">关键字[<%# databinder.eval(container.dataitem,"keyword") %>]</TD>
</tr>
<tr>
<TD align="left" style="TEXT-INDENT: 10pt; BACKGROUND-COLOR: seashell">
内容摘要:<br>
...<%# mid(databinder.eval(container.dataitem,"content"),50,200) %>...<br>
</TD>
</tr>
</ItemTemplate>
</asp:datalist></TABLE>
</TD>
</TR>
<TR>
<TD><FONT face="宋体"><asp:label id="Label1" runat="server"></asp:label><asp:linkbutton id="LinkButton4" runat="server">第一页</asp:linkbutton>
<asp:linkbutton id="LinkButton1" runat="server">上一页</asp:linkbutton><asp:linkbutton id="LinkButton2" runat="server">下一页</asp:linkbutton>
<asp:linkbutton id="LinkButton3" runat="server">末一页</asp:linkbutton></FONT></TD>
</TR>
</TABLE>
</center>
</form>
</body>
</HTML>
ArticlesList.aspx.vb的后台逻辑代码如下:
'---code begin---
Imports System.Web
Imports System.Data
Public Class ArticlesList
Inherits System.Web.UI.Page
#Region " Web 窗体设计器生成的代码 "
'此处省略了设计器生成的无关代码,以节省篇幅
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'在此处放置初始化页的用户代码
If Not Page.IsPostBack Then
viewstate("pagenow") = 0
Dim akinds As String = Request.Params("akind")
Dim seekid As String = Request.Params("seekid")
Dim infor As String = Request.Params("infor")
Dim moreid As String = Request.Params("mo