📄 guestbook.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 Club.Framework;
using Club.Framework.Components;
using Club.Framework.Configuration;
using Club.Framework.Data;
namespace Club.Home
{
/// <summary>
/// guestBook 的摘要说明。
/// </summary>
public class guestBook : System.Web.UI.Page
{
protected Club.Common.WebUI.ContentRegion titleContains;
protected Club.Common.WebUI.ContentRegion headerContains;
protected Club.Common.WebUI.ContentRegion Content;
protected Club.Common.WebUI.SitePage PageManage;
protected Club.Common.GetRequestPage guestBookPage;
protected string Title=string.Empty;
protected int RegisterId
{
get
{
if(Request.Params["RegisterId"]==null||Request.Params["RegisterId"]=="")
{
return 0;
}
return int.Parse(Request.Params["RegisterId"]);
}
}
protected int PageIndex
{
get
{
if(Request.Params["PageIndex"]==null||Request.Params["PageIndex"]=="")
{
return 1;
}
return int.Parse(Request.Params["PageIndex"]);
}
}
protected int LoginRegisterId
{
get
{
try
{
return FormSecurity.GetMemberId();
}
catch
{
return 0;
}
}
}
private c_UserInfo userInfo;
protected c_UserInfo UserInfo
{
get
{
return userInfo;
}
}
private c_HomeSettingInfo setting;
protected c_HomeSettingInfo Setting
{
get
{
return this.setting;
}
}
private void Page_Load(object sender, System.EventArgs e)
{
Ajax.Utility.RegisterTypeForAjax(typeof(guestBook));
if(this.RegisterId==0)
{
throw new ShowException("对不起!没有找到该用户网站!",Globals.UrlFormats.Home());
}
this.userInfo=Globals.DbProvider.Select_c_UserByID(this.RegisterId);
this.setting=Globals.DbProvider.Select_c_HomeSettingByRegisterID(this.RegisterId);
if(this.setting==null)
{
throw new ShowException("您的网站还未设置,请在个人管理设置!",Globals.UrlFormats.Home());
}
//如果不是用户本人并关闭网站提示
if(!setting.IsOpen&&this.RegisterId!=this.LoginRegisterId)
{
throw new ShowException("该网站已经关闭!",Globals.UrlFormats.Home());
}
if(setting.SiteTitle==null||setting.SiteTitle=="")
{
setting.SiteTitle = UserInfo.NiceName + "的网上家园";
}
this.Title=setting.SiteTitle + "-留言";
getPageBind();
Page.DataBind();
}
[Ajax.AjaxMethod()]
public bool guestBookAdd(int registerId,string content,string niceName)
{
c_GuestBookInfo _c_GuestBookInfo=new c_GuestBookInfo();
_c_GuestBookInfo.Content = content;
_c_GuestBookInfo.NiceName = niceName;
_c_GuestBookInfo.PostDate = DateTime.Now;
_c_GuestBookInfo.RegisterID = registerId;
return Globals.DbProvider.Create_c_GuestBookInfo(_c_GuestBookInfo);
}
[Ajax.AjaxMethod()]
public bool deleteGuest(int id)
{
return Globals.DbProvider.Delete_c_GuestBookByID(id);
}
[Ajax.AjaxMethod()]
public bool rePostGuest(int id,string rePost)
{
c_GuestBookInfo _c_GuestBookInfo= Globals.DbProvider.Select_c_GuestBookByID(id);
_c_GuestBookInfo.RePost=rePost;
return Globals.DbProvider.Update_c_GuestBookInfo(_c_GuestBookInfo);
}
private void getPageBind()
{
guestBookPage.TableName = "c_GuestBook";
guestBookPage.PageSize =8;
//articlePage.OrderField = "id";
guestBookPage.OrderType = true;
guestBookPage.IsDataSetPage= false;
string whereStr="RegisterId="+this.RegisterId;
guestBookPage.WhereString =whereStr;
guestBookPage.PageUrlFormatString=Globals.UrlFormats.SiteGuestBook(this.RegisterId,"{0}");
guestBookPage.DataBind();
}
protected string getGuestRePost(int id)
{
if(this.RegisterId!=this.LoginRegisterId)
{
return "alert('你不能回复!')";
}
return "home.RePostGuest("+id+")";
}
protected string getGuestManage(int id)
{
if(this.RegisterId!=this.LoginRegisterId)
{
return "";
}
string reText="管理:<a href=\"javascript:;\" class=\"gsb_btn\" onclick=\"home.getRePostPanel("+id+")\">回复</a> <a href=\"javascript:;\" class=\"gsb_btn\" onclick=\"home.DeleteGuest("+id+")\">删除</a>";
return reText;
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -