📄 searchredirect.cs
字号:
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
// Copyright (c) Telligent Systems Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;using CommunityServer.Components;namespace CommunityServer.Controls
{
/// <summary>
/// Summary description for Summary.
/// </summary>
public class SearchRedirect : SkinnedWebControl
{
string skinFilename = "Skin-SearchRedirect.ascx";
//LinkButton button;
TextBox textbox;
//HtmlGenericControl searchTextValidator;
// *********************************************************************
// SearchRedirect
//
/// <summary>
/// Constructor
/// </summary>
// ***********************************************************************/
public SearchRedirect() : base()
{
if (SkinFilename == null)
SkinFilename = skinFilename;
}
// *********************************************************************
// InitializeSkin
//
/// <summary>
/// Initialize the control template and populate the control with values
/// </summary>
// ***********************************************************************/
override protected void InitializeSkin(Control skin)
{
// Find the search text box
//
textbox = (TextBox) skin.FindControl("SearchText");
// Find the search button
//
Control c = skin.FindControl("SearchButton");
if (c is LinkButton) {
LinkButton b = c as LinkButton;
b.Click += new System.EventHandler(SearchButton_Click);
b.Text = CommunityServer.Components.ResourceManager.GetString("SearchRedirect_SearchButton");
} else if (c is Button) {
Button b = c as Button;
b.Click += new System.EventHandler(SearchButton_Click);
b.Text = CommunityServer.Components.ResourceManager.GetString("SearchRedirect_SearchButton");
}
//searchTextValidator = (HtmlGenericControl) skin.FindControl("SearchTextValidator");
}
// *********************************************************************
// SearchButton_Click
//
/// <summary>
/// Event handler to handle the login button click event
/// </summary>
// ***********************************************************************/
public void SearchButton_Click(Object sender, EventArgs e)
{
if(textbox.Text.Trim() == string.Empty)
Page.Response.Redirect( Globals.GetSiteUrls().Search, true);
string forumsToSearch = "";
if((Page.Request.Path.IndexOf("/photos/") != -1) || (Page.Request.Path.IndexOf("/gallery/") != -1))
{
if(CSContext.Current.ApplicationKey != null)
forumsToSearch = CommunityServer.Search.ForumsToSearchEncode(CSContext.Current.ApplicationKey);
Page.Response.Redirect( Globals.GetSiteUrls().GallerySearchForText( Globals.HtmlEncode(textbox.Text), forumsToSearch ), true );
}
else
{
if (CSContext.Current.ForumID > 0)
forumsToSearch = CommunityServer.Search.ForumsToSearchEncode(CSContext.Current.ForumID.ToString());
Page.Response.Redirect( Globals.GetSiteUrls().SearchForText( Globals.HtmlEncode(textbox.Text), forumsToSearch, "" ), true );
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -