📄 updatecontent.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using ASPNET2BBS;
using System.Data.SqlClient;
public partial class DesktopModules_BBS_UpdateContent : System.Web.UI.Page
{
int nContentID = 0;
int nTitleID = 0;
protected void Page_Load(object sender, EventArgs e)
{
///获取参数的值
if (Request.Params["TitleID"] != null)
{
nTitleID = Int32.Parse(Request.Params["TitleID"].ToString());
}
///获取参数的值
if (Request.Params["ContentID"] != null)
{
nContentID = Int32.Parse(Request.Params["ContentID"].ToString());
}
if (!Page.IsPostBack)
{
if (nContentID > -1)
{
BindContentData(nContentID);
}
}
}
private void BindContentData(int nContentID)
{
ASPNET2BBS.Content content = new ASPNET2BBS.Content();
SqlDataReader recc = content.GetSingleContent(nContentID);
if (recc.Read())
{
Desn.Text = recc["Desn"].ToString();
Body.Text = recc["Body"].ToString();
}
recc.Close();
}
protected void AddBtn_Click(object sender, EventArgs e)
{
///如果页面输入内容合法
if (Page.IsValid == true)
{
///定义类
ASPNET2BBS.Content content = new ASPNET2BBS.Content();
try
{
///修改文章
content.UpdateContent(nContentID,Desn.Text.Trim(),
Body.Text);
///显示操作结果信息
Response.Write("<script>window.alert('" + ASPNET2System.OPERATIONUPDATEFAILUREMESSAGE + "')</script>");
}
catch (Exception ex)
{
///显示修改操作中的失败、错误信息
Response.Redirect("~/DesktopModules/ErrorPage.aspx?ErrorUrl="
+ ASPNET2System.RedirectErrorUrl(Request.RawUrl)
+ "&ErrorMessage=" + ex.Message.Replace("\n", " "));
}
}
}
protected void ReturnBtn_Click(object sender, EventArgs e)
{
///返回管理页面
Response.Redirect("~/DesktopModules/BBS/BBSContent.aspx?TitleID=" + nTitleID.ToString());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -