📄 search.aspx.cs
字号:
//======================================================
//== (c)2008 aspxcms inc by NeTCMS v1.0 ==
//== Forum:bbs.aspxcms.com ==
//== Website:www.aspxcms.com ==
//======================================================
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using NetCMS.Content;
public partial class search : NetCMS.Web.UI.BasePage
{
private string newLine = "\r\n";
protected void Page_Load(object sender, EventArgs e)
{
Response.CacheControl = "no-cache";
string tags = Request.QueryString["tags"];
if (tags == null || tags == string.Empty || tags == "")
{
Response.Write("请填写关键字");
Response.End();
}
else
{
SearchOp();
}
}
protected void SearchOp()
{
Response.Write(SearchLoad());
Response.End();
}
protected string SearchLoad()
{
string SearchTemplet = NetCMS.Publish.General.ReadHtml(GetSearchTemplet());
bool b_C = false;
bool b_P = false;
if (SearchTemplet.IndexOf("{#Page_SearchContent}") > -1)
b_C = true;
if (SearchTemplet.IndexOf("{#Page_SearchPages}") > -1)
b_P = true;
string type = Request.QueryString["type"];
string tags = Request.QueryString["tags"];
string cid = Request.QueryString["ChID"];
int ChID = 0;
if (cid != null && cid != string.Empty)
{
ChID = int.Parse(cid.ToString());
}
if (type == string.Empty && type == null)
{
Response.Write("请选择搜索类型");
Response.End();
}
string date = Request.QueryString["Date"];
string classid = Request.QueryString["ClassID"];
string editor = Request.QueryString["editor"];
string str_List = "<table width=\"100%\" border=\"0\" align=\"center\" cellpadding=\"4\" cellspacing=\"1\">";
str_List += "<tr><td colspan=\"2\">搜索<font color=\"red\"><b>“" + tags + "”</b></font>结果如下:</td></tr>";
NetCMS.Model.SearchInfo si = new NetCMS.Model.SearchInfo();
si.type = type;
si.tags = tags;
si.date = date;
si.classid = classid;
si.chid = ChID;
string curPage = Request.QueryString["page"];
int page = 0;
if (curPage == "" || curPage == null || curPage == string.Empty) { page = 1; }
else
{
try { page = int.Parse(curPage); }
catch
{
page = 1;
}
}
int i, j;
string DTable = string.Empty;
if (ChID != 0)
{
NetCMS.Content.Channel RD = new NetCMS.Content.Channel();
DTable = RD.getChannelTable(ChID);
}
DataTable dt = NetCMS.Content.Search.SearchGetPage(DTable,page, 15, out i, out j, si);
if (dt != null && dt.Rows.Count > 0)
{
for (int k = 0; k < dt.Rows.Count; k++)
{
str_List += getRow(dt.Rows[k],ChID);
}
dt.Clear();
dt.Dispose();
}
else
{
str_List += "<tr>" + newLine + "<td>没有找到相关的记录。" + newLine + "</td>" + newLine + "</tr>";
str_List += "<tr>" + newLine + "<td>请搜索";
string[] sqlser = tags.Split('|');
for (int k = 0; k <sqlser.Length;k++)
{
str_List += "<a target=\"_blank\" href=\"http://www.baidu.com/s?tn=netcms_pg&fyb=1&wd=" + sqlser[k] + "&ie=utf-8\";'><font color=\"red\"><b>" + sqlser[k] + "</b></font></a> ";
}
str_List+="相关结果! " + newLine + "</td>" + newLine + "</tr>";
}
str_List += "</table>";
string str_Page = "<div>" + ShowPage(page, i, j) + "</div>";
if (b_C)
SearchTemplet = SearchTemplet.Replace("{#Page_SearchContent}", str_List);
if(b_P)
SearchTemplet = SearchTemplet.Replace("{#Page_SearchPages}", str_Page);
return SearchTemplet;
}
protected string getRow(DataRow dr,int ChID)
{
string str_Row = "";
string stags = Request.QueryString["tags"];
string FavNewsUrl = string.Empty;
string dim = NetCMS.Config.UIConfig.dirDumm;
if (dim.Trim() != string.Empty)
{
dim = "/" + NetCMS.Config.UIConfig.dirDumm;
}
string NewsUrl = "";
string NewsUrl1 = "";
if (ChID != 0)
{
Channel RD = new Channel();
string dirHTML = NetCMS.Common.Public.readCHparamConfig("htmldir", ChID);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -