?? contentlistpage.cs
字號:
namespace ASPNET.StarterKit.Communities {
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
public delegate ArrayList GetContentItemsDelegate(string username, int sectionID, int pageSize, int pageIndex, string sortOrder);
//*********************************************************************
//
// ContentListPage Class
//
// The base class for all the content list pages.
// e.g., Article Section, Book Section, Events Section page
//
//*********************************************************************
public abstract class ContentListPage : SkinnedCommunityControl {
public GetContentItemsDelegate GetContentItems;
public event SkinLoadEventHandler SkinLoad;
protected ContentList objContentList;
protected Sorter objSorter = null;
//*********************************************************************
//
// TotalRecords Property
//
// Represents the total records that the ContentList will display.
// This information is used by the ContentList pager.
//
//*********************************************************************
public int TotalRecords {
get {
if (ViewState["TotalRecords"] == null)
return -1;
else
return (int)ViewState["TotalRecords"];
}
set { ViewState["TotalRecords"] = value; }
}
//*********************************************************************
//
// SortOrder Property
//
// Represents the sort order of the records when sorting is enabled.
// Notice that it defaults to "Default" which is ContentPage_SortOrder
//
//*********************************************************************
public string SortOrder {
get {
EnsureChildControls();
if (objSorter != null)
return objSorter.SelectedSortOrder;
else
return "Default";
}
}
//*********************************************************************
//
// SkinType Property
//
// The SkinType will always be ContentSkins
//
//*********************************************************************
override protected string SkinType {
get { return "ContentSkins"; }
}
//*********************************************************************
//
// InitializeSkin Method
//
// This method finds the ContentList control and uses the
// GetContentItems method to display values
//
//*********************************************************************
override protected void InitializeSkin(Control skin) {
objContentList = (ContentList)GetControl(skin, "ContentList" );
// Add sorting
objSorter = (Sorter)GetOptionalControl(skin, "Sorter");
if (objSorter != null)
objSorter.OrderChanged += new EventHandler(ContentList_OrderChanged);
if (!Page.IsPostBack) {
if (TotalRecords == -1)
TotalRecords = ContentPageUtility.GetTotalRecords(objSectionInfo.ID);
}
objContentList.TotalRecords = TotalRecords;
// Call Skin Load event
OnSkinLoad(this, new SkinLoadEventArgs(skin));
}
//*********************************************************************
//
// OnSkinLoad Method
//
// Raises the SkinLoad event if anyone is listening
//
//*********************************************************************
protected virtual void OnSkinLoad(Object s, SkinLoadEventArgs e){
if (SkinLoad != null)
SkinLoad(s, e);
}
//*********************************************************************
//
// OnPreRender Method
//
// We bind on each page request to avoid view state
//
//*********************************************************************
protected override void OnPreRender(EventArgs e) {
BindContent();
}
//*********************************************************************
//
// ContentList_OrderChanged Method
//
// When user selects a new sort order, rebind.
//
//*********************************************************************
protected void ContentList_OrderChanged(Object s, EventArgs e) {
objContentList.CurrentPage = 1;
}
//*********************************************************************
//
// BindContent Method
//
// Binds the data source to the ContentList control. Notice that
// this method can be overriden in a derived class.
//
//*********************************************************************
protected virtual void BindContent() {
objContentList.DataSource = GetContentItems(objUserInfo.Username, objSectionInfo.ID, objSectionInfo.RecordsPerPage, objContentList.CurrentPage, SortOrder);
objContentList.DataBind();
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -