使用 ASP.NET Web Forms 模式,繼承 notpage.showTopic 類別:
<%@ Page Language="c#" Codebehind="showTopic.cs" AutoEventWireup="false" Inherits="notpage.showTopic" %>
<html><head>
<meta name="GENERATOR" content="Microsoft Visual Studio 7.0">
<meta name="CODE_LANGUAGE" content="C#"></head>
<body>
<form method="post" runat="server">
<p align="center"><font color="red"><b>檢視留言</b></font></p><br>
<p align="left"><font color="blue">
留言主題:<asp:Label id="n_tdtitle" runat="server" ForeColor="Black"></asp:Label><br>
留言時間:<asp:Label id="n_tdAdddate" runat="server" ForeColor="Black"></asp:Label><br>
留言人:<asp:Label id="n_tdAuthor" runat="server" ForeColor="Black"></asp:Label><br>
留言內容:<asp:Label id="n_tdContent" runat="server" ForeColor="Black"></asp:Label>
</font></p>
</form>
</body></html>
namespace notpage
{
using System;
using System.Web.UI.WebControls;
public class showTopic : System.Web.UI.Page
{
protected Label n_tdAuthor, n_tdContent, n_tdAdddate, n_tdtitle, n_ttitle;
public showTopic()
{
Page.Init += Page_Init;
}
protected void Page_Load(object sender, EventArgs e) { }
protected void Page_Init(object sender, EventArgs e)
{
int int_ID = Convert.ToInt32(Request.QueryString["ID"]);
notepage np = new notepage();
notepage objNp = np.GetTopic(int_ID);
n_tdtitle.Text = objNp.Title;
n_tdContent.Text = objNp.Content;
n_tdAuthor.Text = objNp.Author;
n_tdAdddate.Text = objNp.AddDate.ToString();
InitializeComponent();
}
private void InitializeComponent()
{
this.Load += Page_Load;
}
}
}
Request.QueryString["ID"] 取得留言編號。notepage.GetTopic() 取得資料實體。asp:Label 控制項顯示。InitializeComponent)。