Asp.net源码专业站
首页->博客空间->SpaceBuilderV1.0RC免安装版源码(51aspx调测)>>BasicWebControls/Channel/Search/PhotoSearchResults.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:SpaceBuilderV1.0RC免安装版源码(51aspx调测)
当前文件:文件类型 SpaceBuilderV10RC/BasicWebControls/Channel/Search/PhotoSearchResults.cs[7K,2009-6-12 11:55:43]打开代码结构图
普通视图
		            
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.Controls.BaseClasses; 11using SpaceBuilder.Components; 12using SpaceBuilder.Controls.Utils; 13using System.Web.UI.HtmlControls; 14using System.Web.UI.WebControls; 15using SpaceBuilder.Utils; 16using SpaceBuilder.Galleries.Components; 17using TunyNet.Data.Utils; 18using TunyNet.Utils; 19using SpaceBuilder.Posts.Components; 20using SpaceBuilder.Posts.Providers; 21using SpaceBuilder.Controls; 22 23namespace SpaceBuilder.Search.Controls 24{ 25 public class PhotoSearchResults : TemplatedWebControl 26 { 27 SBContext wlContext; 28 29 SearchResultDataSet<PostSearchItem> pds = null; 30 private int loadedPhotoCount = 0; // 已经加载的图片数目 31 32 protected override void OnInit(EventArgs e) 33 { 34 if (SkinName == null) 35 ExternalSkinFileName = "Searchs/Skin-PhotoSearchResults.ascx"; 36 else 37 ExternalSkinFileName = SkinName; 38 39 wlContext = SBContext.Current; 40 base.OnInit(e); 41 } 42 43 protected override void OnLoad(EventArgs e) 44 { 45 base.OnLoad(e); 46 if (!Page.IsPostBack) 47 DataBind(); 48 } 49 50 public override void DataBind() 51 { 52 base.DataBind(); 53 BindData(); 54 } 55 56 57 Child Controls 68 69 protected override void AttachChildControls() 70 { 71 statusMessage = FindControl("StatusMessage") as StatusMessage; 72 73 noResultsDiv = FindControl("NoResultsDiv") as HtmlControl; 74 listPostsDiv = FindControl("ListPostsDiv") as HtmlControl; 75 searchHint = FindControl("SearchHint") as Literal; 76 77 postsRepeater = FindControl("PostsRepeater") as Repeater; 78 pager = FindControl("Pager") as Pager; 79 80 if (postsRepeater != null) 81 postsRepeater.ItemDataBound += new RepeaterItemEventHandler(PostsRepeater_ItemDataBound); 82 } 83 84 void BindData() 85 { 86 PostFullTextQuery query = new PostFullTextQuery(); 87 query.ConvertFromQueryString(); 88 if (query.IsValid()) 89 { 90 query.PageSize = 16; 91 query.PageIndex = pager.PageIndex; 92 93 pds = PostSearchProvider.Instance().Search(query); 94 postsRepeater.DataSource = pds.Records; 95 postsRepeater.DataBind(); 96 97 if (pds.TotalRecords > 0) 98 { 99 searchHint.Text = "约有 <span class='stress'>" + pds.TotalRecords + " </span>个图片满足搜索条件,搜索用时 " + pds.SearchDuration + ""; 100 101 pager.TotalRecords = pds.TotalRecords; 102 pager.PageSize = query.PageSize; 103 } 104 else 105 { 106 noResultsDiv.Visible = true; 107 listPostsDiv.Visible = false; 108 } 109 } 110 else 111 { 112 listPostsDiv.Visible = false; 113 statusMessage.Visible = true; 114 statusMessage.MessageType = StatusMessageType.Error; 115 statusMessage.Text = "请填写您的搜索条件,再进行搜索"; 116 } 117 } 118 119 private void PostsRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e) 120 { 121 if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) 122 { 123 PostSearchItem item = e.Item.DataItem as PostSearchItem; 124 if (item != null) 125 { 126 this.loadedPhotoCount++; 127 128 GalleryImage thumbnail = e.Item.FindControl("Thumbnail") as GalleryImage; 129 if (thumbnail != null) 130 { 131 thumbnail.PostID = item.PostID; 132 if (!ValueHelper.IsNullOrEmpty(item.PostUrl)) 133 thumbnail.NavigateUrl = Globals.FullPathForMainSite(item.PostUrl); 134 } 135 136 HyperLink subject = e.Item.FindControl("Subject") as HyperLink; 137 if (subject != null) 138 { 139 subject.Text = HtmlUtils.TrimHtml(item.Subject, 20); 140 subject.ToolTip = HtmlUtils.TrimHtml(item.Subject); 141 if (!ValueHelper.IsNullOrEmpty(item.PostUrl)) 142 { 143 subject.NavigateUrl = Globals.FullPathForMainSite(item.PostUrl); 144 subject.Attributes["target"] = "_blank"; 145 } 146 } 147 148 Literal body = e.Item.FindControl("Body") as Literal; 149 if (body != null) 150 body.Text = item.Body; 151 152 HyperLink author = e.Item.FindControl("Author") as HyperLink; 153 if (author != null) 154 { 155 author.Text = item.Author; 156 if (!ValueHelper.IsNullOrEmpty(item.UserProfileUrl)) 157 { 158 author.NavigateUrl = Globals.FullPathForMainSite(item.UserProfileUrl); 159 author.Attributes["target"] = "_blank"; 160 } 161 } 162 163 //HyperLink sectionName = e.Item.FindControl("SectionName") as HyperLink; 164 //if (sectionName != null && !ValueHelper.IsNullOrEmpty(item.SectionName)) 165 //{ 166 // sectionName.Text = item.SectionName; 167 // if (!ValueHelper.IsNullOrEmpty(item.SectionUrl)) 168 // { 169 // sectionName.NavigateUrl = Globals.FullPathForMainSite(item.SectionUrl); 170 // sectionName.Attributes["target"] = "_blank"; 171 // } 172 //} 173 174 Literal tags = e.Item.FindControl("Tags") as Literal; 175 if (tags != null && item.Tags != null) 176 { 177 for (int i = 0; i < item.Tags.Length; i++) 178 { 179 tags.Text += string.Format("<a href='{0}' title='{1}' target='_blank'>{2}</a> ", Globals.FullPathForMainSite(ChannelUrls.Instance().ListPicturesByTag(item.Tags[i])), item.Tags[i], StringUtils.Trim(item.Tags[i], 8)); 180 if (i >= 3) 181 break; 182 } 183 } 184 185 186 } 187 } 188 } 189 190 属性 203 204 } 205} 206
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:SpaceBuilderV1.0RC免安装版源码(51aspx调测)
51Aspx.com 版权所有 CopyRight © 2006-2010. 京ICP备06046876号 本站法律顾问:ITlaw-庄毅雄律师
返回顶部
客户服务:点击这里进行客户咨询 业务合作:点击这里洽谈业务合作 合作热线:010-68880146