📄 topicmenu.cs
字号:
// TopicMenu.cs
//
namespace ASPNET.StarterKit.Communities
{
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Collections.Specialized;
using System.Data;
/// <summary>
/// Summary description for Message.
/// </summary>
public class TopicMenu : SkinnedCommunityControl
{
string _skinFileName = "Topics_TopicMenu.ascx";
ContentList rptTopics;
int _cacheDuration = 10;
int _count = 5;
public int Count
{
get {return _count;}
set {_count = value;}
}
public int CacheDuration
{
get {return _cacheDuration;}
set {_cacheDuration = value;}
}
override protected string SkinType
{
get { return "ControlSkins"; }
}
public TopicMenu() : base()
{
// Assign a default template name
if (SkinFileName == null)
SkinFileName = _skinFileName;
}
override protected void InitializeSkin(Control skin) {
if (objCommunityInfo.EnableTopicMenu) {
// Get the DataList from the Skin
rptTopics = (ContentList)GetControl( skin, "Topics" );
rptTopics.EnableViewState = false;
rptTopics.ItemDataBound += new ContentListItemEventHandler(Repeater_ItemDataBound);
}
}
protected override void OnLoad(EventArgs e)
{
if (objCommunityInfo.EnableTopicMenu) {
EnsureChildControls();
// Bind the results to the DataList
rptTopics.DataSource = TopicUtility.GetLatestTopics(_cacheDuration);
rptTopics.DataBind();
}
}
private void Repeater_ItemDataBound(Object s, ContentListItemEventArgs e)
{
DisplayTopic topic;
TopicInfo _topicInfo;
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
_topicInfo = (TopicInfo)e.Item.DataItem;
topic = (DisplayTopic)GetControl(e.Item, "Topic");
topic.Name = _topicInfo.Name;
topic.Image = _topicInfo.Image;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -