📄 searchresultspanel.ascx.cs
字号:
namespace Interspire.ArticleLive.Web.Templates.SlickFixed.Panels
{
using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Collections;
public abstract class SearchResultsPanel : BaseUserControl
{
protected System.Web.UI.WebControls.Repeater ArticleList;
protected System.Web.UI.WebControls.Panel NoArticlesPanel;
private ArticleEngine articleEngine;
public ArticleEngine ArticleEngine
{
get {
if (articleEngine == null)
articleEngine = new ArticleEngine(Config.Current);
return articleEngine; }
}
protected ArticleSearchCriteria CurrentSearch
{
get { return (ArticleSearchCriteria)ViewState["CurrentSearch"]; }
set { ViewState["CurrentSearch"] = value; }
}
private void Page_Load(object sender, System.EventArgs e)
{
if (Action == "SearchResults")
{
if (Request.QueryString["Query"] != null)
{
WindowTitle = ResourceHelper.GetString("SearchResults");
CurrentSearch = new ArticleSearchCriteria();
CurrentSearch.Query = Request.QueryString["Query"];
CurrentSearch.SearchType = ContentSearchTypeEnum.Word;
try
{
if (Request.QueryString["SearchType"] != null)
CurrentSearch.SearchType = (ContentSearchTypeEnum)Enum.Parse(typeof(ContentSearchTypeEnum), Request.QueryString["SearchType"]);
}
catch
{
// Ignore and continue...
}
ArrayList categoryIDs = new ArrayList();
if (Request.QueryString["CategoryIDs"] != null)
{
string[] stringIDs = Request.QueryString["CategoryIDs"].Split(',');
foreach (string stringID in stringIDs)
{
try
{
categoryIDs.Add(Convert.ToInt32(stringID));
}
catch
{
// Ignore and continue...
}
}
}
CurrentSearch.CategoryIDs = (int[])categoryIDs.ToArray(typeof(int));
if (CurrentSearch.CategoryID == 0)
CurrentSearch.SearchAllCategories = true;
ArticleSet articles = ArticleEngine.SearchArticles(CurrentSearch);
if (articles.Count > 0)
{
ArticleList.Visible = true;
ArticleList.DataSource = articles;
}
else
{
ArticleList.Visible = false;
NoArticlesPanel.Visible = true;
}
DataBind();
Visible = true;
}
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -