?? topicupdate.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>
/// TopicUpdate 的摘要說明。
/// </summary>
public partial class TopicUpdate : System.Web.UI.Page
{
/// <summary>
/// 頁面加載事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, System.EventArgs e)
{
if (!CheckUser())
Response.Redirect("Login.aspx");
if(!IsPostBack)
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);
TextBoxTitle.Text=topic.Title;
TextBoxContent.Text=topic.Content;
LabelCreateTime.Text=topic.CreateTime.ToString();
LabelIP.Text=topic.IP;
LabelUserLoginName.Text=Session["login_name"].ToString();
}
protected void ButtonBack_Click(object sender, System.EventArgs e)
{
Page.Response.Redirect("TopicList.aspx");
}
/// <summary>
/// 修改主題按鈕單擊事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ButtonUpdate_Click(object sender, System.EventArgs e)
{
Topic topic=new Topic();
topic.TopicID=Convert.ToInt32(Request.QueryString["topic_id"]);
Hashtable ht=new Hashtable();
ht.Add("Title",SqlStringFormat.GetQuotedString(TextBoxTitle.Text));
ht.Add("Content",SqlStringFormat.GetQuotedString(TextBoxContent.Text));
topic.Update(ht);
Page.Response.Redirect("TopicList.aspx");
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -