您目前尚未登陆,请选择【登陆】或【注册
首页->博客论坛->SpaceBuilder v1.1源代码>>BlogControls/Club/MyBlogThreadListForClub.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:SpaceBuilder v1.1源代码
当前文件:文件类型 SpaceBuider11/BlogControls/Club/MyBlogThreadListForClub.cs打开代码结构图
普通视图
		            
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.Components; 11using SpaceBuilder.Controls.Utils; 12using System.Web.UI.WebControls; 13using SpaceBuilder.Clubs.Components; 14using SpaceBuilder.Utils; 15using SpaceBuilder.Blogs.Components; 16using SpaceBuilder.Controls; 17using SpaceBuilder.Clubs.Controls; 18using TunyNet.Data.Utils; 19using TunyNet.Utils; 20 21namespace SpaceBuilder.Blogs.Controls 22{ 23 /// <summary> 24 /// 我推荐到圈子里的文章列表 25 /// </summary> 26 public class MyBlogThreadListForClub : ClubDomainThemedControl 27 { 28 private SBContext wlContext = null; 29 30 OnInit 50 51 Child Controls 70 71 protected override void AttachChildControls() 72 { 73 breadCrumb = FindControl("BreadCrumb") as Literal; 74 pageTitle = FindControl("PageTitle") as Literal; 75 76 commendedPostsRepeater = FindControl("CommendedPostsRepeater") as Repeater; 77 pager = FindControl("Pager") as PostBackPager; 78 if (pager != null) 79 { 80 pager.PageIndexChanged += new PagerEventHandler(pager_PageIndexChanged); 81 } 82 83 if (commendedPostsRepeater != null) 84 { 85 commendedPostsRepeater.ItemDataBound += new RepeaterItemEventHandler(CommendedPostsRepeater_ItemDataBound); 86 //commendedPostsRepeater.ItemCommand += new RepeaterCommandEventHandler(CommendedPostsRepeater_ItemCommand); 87 } 88 } 89 90 void pager_PageIndexChanged(object sender, PagerEventArgs e) 91 { 92 Bind(); 93 } 94 95 void Bind() 96 { 97 string title = string.Format("<a href='{0}'>{1}</a> >> <a href='{2}'>博客文章</a>", ClubUrls.Instance().ClubDomainHome(CurrentClub.DomainName), CurrentClub.ClubName, ClubUrls.Instance().BlogHome(CurrentClub.DomainName)); 98 string title2 = CurrentClub.ClubName + " - 博客文章"; 99 100 this.SetPageTitle(title2); 101 if (breadCrumb != null) 102 breadCrumb.Text = title; 103 104 if (pageTitle != null) 105 pageTitle.Text = "我推荐的文章"; 106 107 108 CommendedPostQuery query = new CommendedPostQuery(); 109 query.ClubID = CurrentClub.ClubID; 110 query.ApplicationType = ApplicationType.Blog; 111 query.CommenderUserID = wlContext.User.UserID; 112 113 query.IncludeTags = false; 114 query.PageSize = 15; 115 query.PageIndex = pager.PageIndex; 116 117 PagingDataSet<CommendedPost> pds = CommendedPosts.GetCommendedPosts(query); 118 119 if (pds.TotalRecords > 0) 120 { 121 pager.TotalRecords = pds.TotalRecords; 122 pager.PageSize = query.PageSize; 123 124 commendedPostsRepeater.DataSource = pds.Records; 125 commendedPostsRepeater.DataBind(); 126 } 127 128 } 129 130 private void CommendedPostsRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e) 131 { 132 if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) 133 { 134 CommendedPost cp = e.Item.DataItem as CommendedPost; 135 136 if (cp != null) 137 { 138 BlogThread post = BlogPosts.GetThread(cp.PostID, true); 139 140 HyperLink subject = e.Item.FindControl("Subject") as HyperLink; 141 if (subject != null) 142 { 143 subject.Text = StringUtils.Trim(cp.Subject, 20); 144 if (post.BlogPostType == BlogPostType.Article) 145 subject.Text += "[转帖]"; 146 else if (post.BlogPostType == BlogPostType.Post) 147 subject.Text += "[原创]"; 148 subject.ToolTip = cp.Subject; 149 subject.NavigateUrl = BlogUrls.Instance().ShowPost(post); 150 subject.Attributes["target"] = "_blank"; 151 } 152 153 HyperLink author = e.Item.FindControl("Author") as HyperLink; 154 if (author != null) 155 { 156 author.Text = StringUtils.Trim(cp.Author, 20); 157 author.ToolTip = "查看 " + cp.Author + " 的空间"; 158 author.NavigateUrl = UserUrls.Instance().UserChannelHome(cp.AuthorUserID, UserDomainMenuType.Profile); 159 author.Attributes["target"] = "_blank"; 160 } 161 162 Literal replies = e.Item.FindControl("Replies") as Literal; 163 if (replies != null) 164 replies.Text = post.ReplyCount.ToString(); 165 166 Literal totalViews = e.Item.FindControl("TotalViews") as Literal; 167 if (totalViews != null) 168 totalViews.Text = post.HitTimes.ToString(); 169 170 Literal postDate = e.Item.FindControl("PostDate") as Literal; 171 if (postDate != null) 172 postDate.Text = Formatter.FormatDate(post.PostDate); 173 174 Literal tagNames = e.Item.FindControl("TagNames") as Literal; 175 if (tagNames != null && post.Tags.Count > 0) 176 { 177 foreach (ClubTag tag in cp.Tags) 178 { 179 tagNames.Text += tag.TagName + ","; 180 } 181 if (tagNames.Text.Length > 0) 182 tagNames.Text = tagNames.Text.TrimEnd(new char[] { ',' }); 183 } 184 185 HyperLink commender = e.Item.FindControl("Commender") as HyperLink; 186 if (commender != null) 187 { 188 commender.Text = StringUtils.Trim(cp.Commender, 20); 189 commender.ToolTip = "查看 " + cp.Author + " 的空间"; 190 commender.NavigateUrl = UserUrls.Instance().UserChannelHome(cp.CommenderUserID, UserDomainMenuType.Profile); 191 commender.Attributes["target"] = "_blank"; 192 } 193 194 Literal commendedDate = e.Item.FindControl("CommendedDate") as Literal; 195 if (commendedDate != null) 196 commendedDate.Text = Formatter.FormatDate(cp.CommendedDate); 197 } 198 } 199 } 200 201 } 202} 203 204
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:SpaceBuilder v1.1源代码