📄 sendtheme.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;
public partial class SendTheme : System.Web.UI.Page
{
Code code = new Code();
Theme theme = new Theme();
Controls ctrl = new Controls();
Users user = new Users();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Response.Expires = 0;
Response.Cache.SetNoStore();
Response.AppendHeader("Pragma", "no-cache");
btnSend.Attributes.Add("onclick", "CheckForm()");
BindDdl();
BindRbl();
if(!Equals(UserInfo.GetThemeId,null))
ShowEditInfo();
}
}
/// <summary>
/// 显示编辑帖子内容
/// </summary>
private void ShowEditInfo()
{
#region
DataView mydv = theme.GetThemeEdit(UserInfo.GetThemeId);
string strTitle = mydv[0]["title"].ToString();
ddlType.SelectedItem.Text = strTitle.Substring(1, 2);
rblHeart.SelectedValue = mydv[0]["typeid"].ToString();
txtTitle.Text = strTitle.Remove(0, 4);
content.Value = mydv[0]["content"].ToString();
content.Attributes.Add("onload", "CheckForm()");
#endregion
}
/// <summary>
/// 发布修改帖子
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Button1_Click(object sender, EventArgs e)
{
#region
if (!Equals(UserInfo.GetUserName, null))
{
if (Equals(UserInfo.GetThemeId, null))
{
string strContent = StringUtil.GetHtmlEditReplace(content.Value);
if (strContent.Length > 20000)
JScript.Alert("主题内容不能超过20000字符!");
else
{
string strThemeId = theme.AddTheme("[" + ddlType.SelectedItem.Text + "] " + ctrl.GetText(txtTitle), strContent, UserInfo.GetUserName, QueryString.GetSmallId,rblHeart.SelectedValue);
if (!Equals(strThemeId, "0"))
Response.Redirect("SavePost.aspx?bigid=" + QueryString.GetBigId + "&smallid=" + QueryString.GetSmallId + "&themeid=" + strThemeId);
else
JScript.Alert("发布失败!");
}
}
else
{
string strContent = StringUtil.GetHtmlEditReplace(content.Value)+"<br>此贴于 "+DateTime.Now.ToString()+" 被编辑过!";
if (strContent.Length > 20000)
JScript.Alert("主题内容不能超过20000字符!");
else
{
if (theme.ChangeTheme(UserInfo.GetThemeId, "[" + ddlType.SelectedItem.Text + "] " + ctrl.GetText(txtTitle), strContent,rblHeart.SelectedValue))
{
Response.Cookies["themeid"].Expires = DateTime.Now.AddMinutes(-1);
Response.Redirect("SavePost.aspx?bigid=" + QueryString.GetBigId + "&smallid=" + QueryString.GetSmallId + "&themeid=" + QueryString.GetThemeId);
}
else
JScript.Alert("修改失败!");
}
}
}
else
JScript.Alert("请先登录!");
#endregion
}
/// <summary>
/// 绑定类型
/// </summary>
private void BindDdl()
{
ctrl.BindDropDownList(ddlType, code.Dv_Type(), "name", "id", "");
}
/// <summary>
/// 绑定心情
/// </summary>
private void BindRbl()
{
#region
for (int i = 1; i < 19; i++)
{
rblHeart.Items.Add("<img alt=\"心情\" src=\"images/heart/face"+i.ToString()+".gif\" />");
rblHeart.Items[i-1].Value = i.ToString();
}
rblHeart.Items[0].Selected = true;
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -