📄 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;
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.Redirect("Login.aspx");
InitData();
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
}
#endregion
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());
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -