📄 threadedit.cs
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using NetFocus.Web.Core;
namespace NetFocus.Web.Applications.Forum
{
public class ThreadEdit : UserControl
{
protected ValuedTextBox subjectTextBox;
protected ValuedTextBox tagsTextBox;
protected ValuedDropDownList threadTypeDropDownList;
protected ValuedEditor bodyEditor;
protected ResourceButton saveButton;
protected override void OnLoad(EventArgs e)
{
if (!Page.IsPostBack && !AjaxManager.IsCallBack)
{
BindData();
}
saveButton.Click += new EventHandler(SaveArticle);
}
private void BindData()
{
threadTypeDropDownList.Items.Add(new ListItem("正常", "0"));
threadTypeDropDownList.Items.Add(new ListItem("推荐", "1"));
threadTypeDropDownList.Items.Add(new ListItem("置顶", "2"));
threadTypeDropDownList.Items.Add(new ListItem("精华", "3"));
Thread thread = BusinessManager.GetThread(RequestBuilder.BuildThreadRequest(WebContext.Current.EntityId)) as Thread;
if (thread != null)
{
subjectTextBox.Value = thread.Subject;
bodyEditor.Value = thread.Body;
tagsTextBox.Value = thread.Tags;
threadTypeDropDownList.Value = thread.ThreadType.ToString();
}
}
private void SaveArticle(object sender, EventArgs e)
{
//获取当前帖子
Thread thread = BusinessManager.GetThread(RequestBuilder.BuildThreadRequest(WebContext.Current.EntityId)) as Thread;
//设置帖子属性
thread.Subject = subjectTextBox.Value;
thread.Body = bodyEditor.Value;
thread.Tags = tagsTextBox.Value;
thread.ThreadType = int.Parse(threadTypeDropDownList.Value);
if (thread.ThreadType == (int)ThreadType.Stick)
{
thread.StickDate = DateTime.Now;
}
//更新帖子
BusinessManager.UpdateThread(thread);
//返回列表页面
Page.Response.Redirect(SiteUrls.Instance().GetThreadListUrl(thread.SectionId));
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -