我想在我的网站中加入站内搜索功能,希望大神们能教一下,最好能将实现的程序贴一下。谢谢。
页面设置代码:<%@ Control Language="C#" AutoEventWireup="true" CodeFile="InfoSearch.ascx.cs" Inherits="UserControl_InfoSearch" %>
<table align="center" cellpadding="0" cellspacing="0" width="184">
<tr>
<td align="left" class="henhong">
输入关键字</td>
</tr>
<tr>
<td align="left">
<asp:TextBox ID="txtKey" runat="server" CssClass="TextBox" Width="184px"></asp:TextBox></td>
</tr>
<tr>
<td align="left" height="36">
<a href="#"></a>
<asp:ImageButton ID="ImageButton1" runat="server" AlternateText="开始搜索" Height="22px"
Width="67px" OnClick="ImageButton1_Click" ImageUrl="~/images/anhiu1.jpg" />
<asp:ImageButton ID="ImageButton2" runat="server" AlternateText="搜索帮助?" Height="22px"
Width="67px" ImageUrl="~/images/anhiu2.jpg" PostBackUrl="~/Help.aspx" /><a href="#"></a></td>
</tr>
</table>
后代部分代码
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;
public partial class UserControl_InfoSearch : System.Web.UI.UserControl
{
static string infoType = ""; //信息类型
Operation operation = new Operation();
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
Session["key"] = txtKey.Text;
if (Page.Title.Length == 5) //主页中查询
{
infoType = "招聘信息";
Response.Redirect("ShowPage/webZP.aspx");
return;
}
else
{
infoType = Page.Title.Substring(7, 4);
}
switch (infoType) //分页中信息查询
{
case "招聘信息":
Response.Redirect("../ShowPage/webZP.aspx");
break;
case "求职信息":
Response.Redirect("../ShowPage/webQZ.aspx");
break;
case "培训信息":
Response.Redirect("../ShowPage/webPX.aspx");
break;
case "公寓信息":
Response.Redirect("../ShowPage/webGY.aspx");
break;
case "家教信息":
Response.Redirect("../ShowPage/webJJ.aspx");
break;
case "物品求购":
Response.Redirect("../ShowPage/webWPQG.aspx");
break;
case "物品出售":
Response.Redirect("../ShowPage/webWPCS.aspx");
break;
case "求兑出兑":
Response.Redirect("../ShowPage/webQDCD.aspx");
break;
case "车辆信息":
Response.Redirect("../ShowPage/webCL.aspx");
break;
case "寻求合作":
Response.Redirect("../ShowPage/webXQHZ.aspx");
break;
case "企业广告":
Response.Redirect("../ShowPage/webQYGG.aspx");
break;
}
}
}
以你这问题体现出来的信息.
百度站内搜索非常适合你
用lucene.net实现站内搜索,因为搜索可能涉及到很多不同表,用这个可以把相关索引数据放到一起,实现站内搜索
园子的站内搜索貌似是谷歌?还是百度?搜索本站的东西