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