显示列表list.aspx
1@ Page language="c#" Codebehind="list.cs" AutoEventWireup="false" Inherits="notpage.list"
1<html><head>
2<meta content="Microsoft Visual Studio 7.0" name="GENERATOR"/>
3<meta content="C#" name="CODE_LANGUAGE"/></head>
4<body>
5<form method="post" runat="server"><p> </p></form><a href="addTopic.aspx">发表留言</a><br/>
6<table border="0" cellpadding="2" cellspacing="2" height="1" id="liuyan" width="90%">
7<tr>
8<td>主题</td>
9<td>留言人</td>
10<td>留言时间</td>
11</tr>
12<asp:label id="n_tdtitle" runat="Server"></asp:label>
13</table><p> </p></body></html>
namespace notpage
{
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
1<p> </p>
1<p>
2/// <summary>
3/// Summary description for list.
4/// </summary>
5public class list : System.Web.UI.Page
6{
7protected System.Web.UI.WebControls.Label n_tdtitle;
8
9public list()
10{
11Page.Init += new System.EventHandler(Page_Init);
12}</p>
1<p> protected void Page_Load(object sender, EventArgs e)
2{
3if (!IsPostBack)
4{
5//
6// Evals true first time browser hits the page
7//
8}
9}</p>
1<p> protected void Page_Init(object sender, EventArgs e)
2{
3//
4// CODEGEN: This call is required by the ASP+ Windows Form Designer.
5//
6InitializeComponent();
7Init_tdtitle();
8</p>
1<p> }
2</p>
1<p> /// <summary>
2/// Required method for Designer support - do not modify
3/// the contents of this method with the code editor.
4/// </summary>
5private void InitializeComponent()
6{
7this.Load += new System.EventHandler (this.Page_Load);
8}
9
10protected void Init_tdtitle()
11{
12InitializeComponent();
13//
14// CODEGEN: This call is required by the ASP+ Windows Form Designer.
15//
16try
17{
18notepage np = new notepage();</p>
1<p> ArrayList arrTopic = np.GetTopicList();
2
3for ( int i = 0 ; i < arrTopic.Count ; i ++)
4{
5notepage objTopic = (notepage)arrTopic[i] ;
6string str ="<tr><td><a href='showTopic.aspx?id="+objTopic.ID.ToString()+"'>" + objTopic.Title.ToString() + "</a></td>";
7str = str +"<td>" + objTopic.Author.ToString()+"</td>";
8str = str +"<td>" + objTopic.adddate.ToString()+"</td></tr>";
9n_tdtitle.Text = str + n_tdtitle.Text;
10}
11}
12catch(Exception e)
13{
14throw(new Exception("取得贴子列表出错:" + e.ToString())) ;
15}</p>
1<p> }
2}
3}</p>