温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:SpaceBuilder v1.0正式版源码
当前文件:
SpaceBuiderV10Source/BasicWebControls/Manage/Forum/ShowForumSections.cs[8K,2009-6-12 11:55:07],打开代码结构图
SpaceBuiderV10Source/BasicWebControls/Manage/Forum/ShowForumSections.cs[8K,2009-6-12 11:55:07],打开代码结构图1//------------------------------------------------------------------------------ 2
// <copyright company="Tunynet"> 3
// Copyright (c) Tunynet Network Technology Co., Ltd. All rights reserved. 4
// </copyright> 5
//------------------------------------------------------------------------------ 6
7
using System; 8
using System.Collections.Generic; 9
using System.Text; 10
using SpaceBuilder.Web.Manage.Controls; 11
using System.Web.UI.WebControls; 12
using SpaceBuilder.Forums.Components; 13
using System.Web.UI.HtmlControls; 14
15
namespace SpaceBuilder.Web.Manage.Controls 16
{ 17
public class ShowForumSections : ForumBaseControl 18
{ 19
protected override void OnInit(EventArgs e) 20
{ 21
if (SkinName == null) 22
{ 23
SkinName = "Forums/Skin-ShowForumSections.ascx"; 24
} 25
base.OnInit(e); 26
} 27
28
... 33
34
protected override void AttachChildControls() 35
{ 36
forumSectionListRepeater = FindControl("ForumSectionListRepeater") as Repeater; 37
forumSectionListRepeater.ItemDataBound += new RepeaterItemEventHandler(forumSectionListRepeater_ItemDataBound); 38
forumSectionListRepeater.ItemCommand += new RepeaterCommandEventHandler(forumSectionListRepeater_ItemCommand); 39
} 40
41
protected override void OnPreRender(EventArgs e) 42
{ 43
EnsureChildControls(); 44
//if (!Page.IsPostBack) 45
BindData(); 46
base.OnPreRender(e); 47
} 48
49
private void BindData() 50
{ 51
if (ChildeForumSections == null || ChildeForumSections.Count <= 0) 52
return; 53
else 54
{ 55
if (forumSectionListRepeater != null) 56
{ 57
forumSectionListRepeater.DataSource = ChildeForumSections; 58
forumSectionListRepeater.DataBind(); 59
} 60
} 61
} 62
63
void forumSectionListRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e) 64
{ 65
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) 66
{ 67
Forum forumSection = (Forum)e.Item.DataItem; 68
if (forumSection != null) 69
{ 70
Literal prefix = e.Item.FindControl("Prefix") as Literal; 71
if (prefix != null) 72
{ 73
prefix.Text = PrefixForDepth(forumSection.Depth); 74
} 75
Literal sortOrder = e.Item.FindControl("SortOrder") as Literal; 76
if (sortOrder != null) 77
{ 78
sortOrder.Text = forumSection.SortOrder.ToString(); 79
} 80
Literal forumSectionName = e.Item.FindControl("ForumSectionName") as Literal; 81
if (forumSectionName != null) 82
{ 83
forumSectionName.Text = forumSection.SectionName; 84
} 85
Literal sectionOwner = e.Item.FindControl("SectionOwner") as Literal; 86
if (sectionOwner != null) 87
{ 88
string moderatorString = string.Empty; 89
if (forumSection.Moderators.Count > 0) 90
{ 91
foreach (ForumModerator moderator in forumSection.Moderators) 92
{ 93
moderatorString += moderator.DisplayName + ","; 94
} 95
if (moderatorString.EndsWith(",")) 96
moderatorString = moderatorString.Substring(0, moderatorString.Length - 1); 97
} 98
sectionOwner.Text = moderatorString; 99
} 100
Literal description = e.Item.FindControl("Description") as Literal; 101
if (description != null) 102
{ 103
description.Text = forumSection.Description; 104
} 105
LinkButton editButton = e.Item.FindControl("EditButton") as LinkButton; 106
if (editButton != null) 107
{ 108
editButton.CommandArgument = forumSection.SectionID.ToString(); 109
} 110
LinkButton deleteButton = e.Item.FindControl("DeleteButton") as LinkButton; 111
if (deleteButton != null) 112
{ 113
deleteButton.CommandArgument = forumSection.SectionID.ToString(); 114
if (forumSection.ChildCount > 0) 115
{ 116
deleteButton.Attributes["onclick"] = string.Format("if(!confirm(\"此版块下的{0}个子版块将同时删除,您还确认要删除此版块吗?\")) return false;", forumSection.ChildCount); 117
} 118
else 119
deleteButton.Attributes["onclick"] = "if(!confirm(\"确认要删除此版块吗?\")) return false;"; 120
} 121
LinkButton addButton = e.Item.FindControl("AddButton") as LinkButton; 122
if (addButton != null) 123
{ 124
addButton.CommandArgument = forumSection.SectionID.ToString(); 125
} 126
//if (forumSection.ChildForums.Count > 0) 127
//{ 128
// HtmlTableRow childForumSectionsTr = e.Item.FindControl("ChildForumSectionsTr") as HtmlTableRow; 129
// if (childForumSectionsTr != null) 130
// { 131
// childForumSectionsTr.Visible = true; 132
// ShowForumSections showChildeForums = e.Item.FindControl("ShowChildeForums") as ShowForumSections; 133
// if (showChildeForums != null) 134
// { 135
// showChildeForums.Visible = true; 136
// showChildeForums.ChildeForumSections = forumSection.ChildForums; 137
// } 138
// } 139
//} 140
} 141
} 142
} 143
144
private string PrefixForDepth(int p) 145
{ 146
string prefixString = string.Empty; 147
for (int i = 0; i < p; i++) 148
{ 149
prefixString += " "; 150
} 151
return prefixString; 152
} 153
154
void forumSectionListRepeater_ItemCommand(object source, RepeaterCommandEventArgs e) 155
{ 156
switch (e.CommandName) 157
{ 158
case "Edit": 159
Context.Response.Redirect(ForumUrls.Instance().Manage_EditForumSection(Convert.ToInt32(e.CommandArgument))); 160
break; 161
case "Delete": 162
Forum f = Forums.Components.Forums.GetForum(Convert.ToInt32(e.CommandArgument)); 163
if (f != null) 164
{ 165
Forums.Components.Forums.Delete(f); 166
} 167
ReBindData(); 168
break; 169
case "Add": 170
Context.Response.Redirect(ForumUrls.Instance().Manage_AddChildForumSection(Convert.ToInt32(e.CommandArgument))); 171
break; 172
default: 173
break; 174
} 175
} 176
177
private void ReBindData() 178
{ 179
if (ForumGroupID > 0) 180
{ 181
ForumQuery query = new ForumQuery(); 182
query.ClubID = ForumGroupID; 183
query.ForumType = ForumType.Normal; 184
query.OrganizeOption = ForumsOrganizeOption.Indented; 185
query.SortBy = SpaceBuilder.Posts.Components.SortSectionsBy.MostRecentPostDate; 186
query.ActiveStatus = SpaceBuilder.Components.ActiveStatus.All; 187
IList<Forum> forumsIn = Forums.Components.Forums.GetForumsByClubID(query); 188
this.childeForumSections = forumsIn; 189
BindData(); 190
} 191
} 192
193
... 217
} 218
} 219






}
}