项目调试之供求网站信息开发----实现网页中搜索匹配查询功能

最近在完成一个拿得出手的小型项目,主要对供求网站信息进行发布、管理,等操作,今天正好完善到全局搜索功能,仅供大家参考学习:

效果图:

前台代码:

<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>
&nbsp;<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>

后台cs:

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;
}
}
}

posted @ 2011-05-25 17:34  brainmao  阅读(667)  评论(0编辑  收藏  举报