Asp.net源码专业站
首页->博客空间->SpaceBuilder v1.0正式版源码>>BasicWebControls/Manage/Forum/ShowForumSections.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:SpaceBuilder v1.0正式版源码
当前文件:文件类型 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 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 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
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:SpaceBuilder v1.0正式版源码
51Aspx.com 版权所有 CopyRight © 2006-2010. 京ICP备06046876号 本站法律顾问:ITlaw-庄毅雄律师
返回顶部
客户服务:点击这里进行客户咨询 业务合作:点击这里洽谈业务合作 合作热线:010-68880146