📄 comments.cs
字号:
namespace ASPNET.StarterKit.Communities {
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
using System.ComponentModel;
//*********************************************************************
//
// Comments Class
//
// WebControl that displays all the comments on a content page.
//
//*********************************************************************
[Designer(typeof(ASPNET.StarterKit.Communities.CommunityDesigner))]
public class Comments : SkinnedCommunityControl {
string _skinFileName = "Comments_DisplayComments.ascx";
string _headerTemplate = "Comments_DisplayComments-HeaderTemplate";
string _itemTemplate = "Comments_DisplayComments-ItemTemplate";
string _separatorTemplate = "Comments_DisplayComments-SeparatorTemplate";
string _footerTemplate = "Comments_DisplayComments-FooterTemplate";
Panel pnlComments;
DropDownList dropCommentView;
DropDownList dropOrderBy;
ContentList ctlCommentList;
int commentView;
CommentCollection colComments;
ContentInfo objContentInfo;
//*********************************************************************
//
// DisplayComments Constructor
//
// Calls the base SkinnedCommunityControl constructor
// and assigns the default page skin.
//
//*********************************************************************
public Comments() : base() {
// Assign a default template name
if (SkinFileName == null)
SkinFileName = _skinFileName;
// Get ContentInfo
if (Context != null) {
objContentInfo = (ContentInfo)Context.Items["ContentInfo"];
ContentPageID = objContentInfo.ContentPageID;
}
}
//*********************************************************************
//
// SkinType Property
//
// Specifies the skins directory where this page's skin file is located.
//
//*********************************************************************
override protected string SkinType {
get { return "ControlSkins"; }
}
//*********************************************************************
//
// ContentPageID Property
//
// Represents the Content Page ID of the resource being commented on.
//
//*********************************************************************
public int ContentPageID {
get {
if (ViewState["ContentPageID"] == null)
return -1;
else
return (int)ViewState["ContentPageID"];
}
set {ViewState["ContentPageID"] = value; }
}
//*********************************************************************
//
// HeaderTemplate Property
//
// Represents the name of the Header Template used with the Repeater
// for the comments.
//
//*********************************************************************
public string HeaderTemplate {
get {return _headerTemplate;}
set {_headerTemplate = value;}
}
//*********************************************************************
//
// ItemTemplate Property
//
// Represents the name of the Item Template used with the Repeater
// for the comments.
//
//*********************************************************************
public string ItemTemplate {
get {return _itemTemplate;}
set {_itemTemplate = value;}
}
//*********************************************************************
//
// SeparatorTemplate Property
//
// Represents the name of the Separator Template used with the Repeater
// for the comments.
//
//*********************************************************************
public string SeparatorTemplate {
get {return _separatorTemplate;}
set {_separatorTemplate = value;}
}
//*********************************************************************
//
// FooterTemplate Property
//
// Represents the name of the Footer Template used with the Repeater
// for the comments.
//
//*********************************************************************
public string FooterTemplate {
get {return _footerTemplate;}
set {_footerTemplate = value;}
}
//*********************************************************************
//
// InitializeSkin Method
//
// Retrieves all the controls from the page skin.
//
//*********************************************************************
override protected void InitializeSkin(Control skin) {
// Find Comments Panel
pnlComments = (Panel)GetControl(skin, "pnlComments");
// Find the Comment View DropDownList
dropCommentView = (DropDownList)GetControl(skin, "CommentView");
dropCommentView.AutoPostBack = true;
// Find the OrderBy DropDownList
dropOrderBy = (DropDownList)GetControl(skin, "OrderBy");
dropOrderBy.AutoPostBack = true;
// Get the Comment List
ctlCommentList = (ContentList)GetControl(skin, "CommentList");
ctlCommentList.EnableViewState = false;
}
//*********************************************************************
//
// OnLoad Method
//
// Assigns values to the controls from the page skin.
//
//*********************************************************************
protected override void OnLoad(EventArgs e) {
if (Visible && ContentPageID != -1) {
EnsureChildControls();
// determine comment view
if (!Page.IsPostBack && Context.Session["CommentView"] != null) {
commentView = (int)Context.Session["CommentView"];
dropCommentView.SelectedIndex = -1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -