TopicDetail.aspx
<%@ Page Language="c#" Inherits="MyBBS.Web.TopicDetail" CodeFile="TopicDetail.aspx.cs" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>帖子详细信息</title>
<link href="Styles/Style.css" type="text/css" rel="stylesheet" />
</head>
<body>
<form id="Form1" method="post" runat="server">
<table id="Table1" style="z-index: 101; left: 9px; width: 690px; position: absolute;
top: 16px; height: 311px" cellspacing="0" cellpadding="0" border="0">
<tr>
<td>
>>帖子列表>>详细信息
<hr/>
</td>
</tr>
<tr>
<td style="height: 28px">
<p>
【
<asp:Label ID="LabelTitle" runat="server"></asp:Label>】 by
<asp:Label ID="LabelUserLoginName" runat="server"></asp:Label>|
<asp:Label ID="LabelIP" runat="server"></asp:Label>|
<asp:Label ID="LabelCreateTime" runat="server"></asp:Label><br/>
<asp:Label ID="LabelContent" runat="server"></asp:Label>
</p>
<hr/>
<b>以下为本主题回复信息:</b>
<hr/>
<p>
</p>
</td>
</tr>
<tr>
<td>
<asp:Label ID="LabelReplyList" runat="server" ForeColor="Black"></asp:Label></td>
</tr>
<tr>
<td align="center">
<asp:Button ID="ButtonReply" runat="server" Width="46px" Text="回复" OnClick="ButtonReply_Click">
</asp:Button>
<asp:Button ID="ButtonBack" runat="server" Width="48px" Text="返回" OnClick="ButtonBack_Click">
</asp:Button></td>
</tr>
</table>
</form>
</body>
</html>
TopicDetail.aspx.cs
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;
using MyBBS.BusinessLogicLayer;
using MyBBS.DataAccessHelper;
//该源码下载自www.51aspx.com(51aspx.com)
namespace MyBBS.Web
{
/// <summary>
/// TopicDetail 的摘要说明。
/// </summary>
public partial class TopicDetail : System.Web.UI.Page
{
protected void Page_Load(object sender, System.EventArgs e)
{
if (!CheckUser())
Response.Write("<script language='javascript'>window.open('" + "登录.aspx" + "')</script>");
InitData();
}
private bool CheckUser()
{
if(Session["login_name"]==null)
{
Response.Write("<Script Language=JavaScript>alert('请登录!');</Script>");
return false;
}
return true;
}
/// <summary>
/// 初始化页面数据
/// </summary>
private void InitData()
{
int topicID=Convert.ToInt32(Request.QueryString["topic_id"]);
Topic topic=new Topic();
topic.LoadData(topicID);
LabelTitle.Text=topic.Title;
LabelContent.Text=System.Web.HttpUtility.HtmlEncode(topic.Content);
LabelCreateTime.Text=topic.CreateTime.ToString();
LabelIP.Text=topic.IP;
LabelUserLoginName.Text=topic.UserLoginName;
//输出回复信息
DataSet dsReplis=topic.QueryReplies();
foreach(DataRow row in dsReplis.Tables[0].Rows)
{
LabelReplyList.Text+="【"+GetSafeData.ValidateDataRow_S(row,"Title")+"】";
LabelReplyList.Text+=" by ";
LabelReplyList.Text+=GetSafeData.ValidateDataRow_S(row,"LoginName");
LabelReplyList.Text+=" | ";
LabelReplyList.Text+=GetSafeData.ValidateDataRow_S(row,"IP");
LabelReplyList.Text+=" | ";
LabelReplyList.Text+=GetSafeData.ValidateDataRow_T(row,"CreateTime").ToString();
LabelReplyList.Text+="<br>";
LabelReplyList.Text+=GetSafeData.ValidateDataRow_S(row,"Content");
LabelReplyList.Text+="<hr>";
}
}
protected void ButtonBack_Click(object sender, System.EventArgs e)
{
Response.Redirect("TopicList.aspx");
}
/// <summary>
/// “回复”按钮单击事件:跳转到回复页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ButtonReply_Click(object sender, System.EventArgs e)
{
Response.Redirect("TopicReply.aspx?topic_id="+Request.QueryString["topic_id"].ToString());
}
}
}