⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 topicupdate.aspx.cs

📁 c# 李子全集 初学者的法宝 文档全集
💻 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 + -