<%@ Page Language="C#" AutoEventWireup="true" CodeFile="searchcom.aspx.cs" Inherits="member_searchcom" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<style type="text/css">
<!--
.mouseOut
{
font-size:15px;
background: #ffffff;
color: #000000;
}
.mouseOver
{
font-size:15px;
background: #3366cc;
color: #ffffff;
cursor: pointer;
}
-->
</style>
<title>无标题页</title>
<script language="javascript" src="https://www.jb51.net/js/suggest.js" type="text/javascript"></script>
</head>
<body>
<form runat="server">
<div>
<table>
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td >
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td><input type="text" maxlength="20" onkeyup="findNames(event);" onkeydown="updown(event);"/>
<div>
<table bgcolor="#FFFAFA" cellspacing="0" cellpadding="3px">
<tbody></tbody>
</table>
</div>
</td>
</tr>
</table>
<br />
<br />
<br />
</div>
</form>
</body>
</html>
3.后台处理页面
复制代码 代码如下:
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 System.Data.SqlClient;
using CaiHong.DBUtility;
public partial class member_SearchCompany : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//获取你自己的数据库连接连接。数据库调用,采用了SqlHelper,要想使用下面代码,下载SqlHelper到你自己定义文件夹,然后添加引用。否在请自行编写数据库访问代码。
string strconn = ConfigurationManager.ConnectionStrings["DBConn"].ConnectionString;
string keyword = Request.QueryString["cname"];
string sql = "select Member_TrueName from users where Member_TrueName like '%" + @keyword + "%' and Member_ShenFen=1 order by id desc";
SqlParameter spr = new SqlParameter("@keyword", SqlDbType.NVarChar, 50);
spr.Value = keyword;
Response.ContentType = "text/xml";
Response.Write("<?xml version=\"1.0\" encoding=\"GB2312\"?>");
Response.Write("<response>");
using (SqlConnection sqlconn = new SqlConnection(strconn))
{
sqlconn.Open();
SqlDataReader dre = SqlHelper.ExecuteReader(sqlconn, CommandType.Text, sql);
if (dre.HasRows)
{
while (dre.Read())
{
Response.Write("<content>");
Response.Write("<name>" + dre.GetString(0) + "</name>");
Response.Write("</content>");
}
}
else
{
Response.Write("<content>");
Response.Write("<name>IsKong</name>");
Response.Write("</content>");
}
Response.Write("</response>");
dre.Close();
}
}
}
您可能感兴趣的文章: