您的位置:首页 > 服装鞋帽 > 女装 > AJAX实现google输入自动完成的简单模拟

AJAX实现google输入自动完成的简单模拟

luyued 发布于 2011-06-21 10:44   浏览 N 次  
比较简单的模拟,文本框输入CompanyName,然后搜索SqlServer2000 里NorthWind数据库 Suppliers表的CompanyName字段,然后实现自动完成( d& t( ^8 [! U: N4 k/ g
) B# A# h; x1 o/ Y4 Y; {6 S
四个文件8 g1 |4 I& U: V; K
1 .AutoComplete.htm

_" D. U: \9 ~8 X3 J. j6 f1 g6 d

输入自动完成/ D1 d" T( ~3 o, z& |
6 n* v% ^0 J I) w( i7 W
% V2 Q2 {. e9 Q* R1 \4 a4 R Q, j
initPar()">4 U% B4 |7 R! i6 |
CompanyNameautoComplete()" COLOR: #8b0000">setDisplay();" style="width:400px"/>
1 g- z1 P! \) x1 v


. `9 j# S/ Q- E+ Y& n


+ g2 v4 W4 N* y: C. b3 b8 g* \

AutoComplete.aspx% t- ]- L& R6 y8 z% {
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AutoComplete.aspx.cs" Inherits="AJAXBaseHome.AutoComplete" %>

) r! V0 ?0 y/ F0 {+ [' I: E
AutoComplete.aspx.cs
using System;
using System.Data;( S4 Y+ ~$ y! K3 {
using System.Data.SqlClient;* o' Q6 [ y J7 _! r
using System.Configuration;! B; w+ T! m( W* S
using System.Collections;* ` }0 B5 ^0 e
using System.IO;
using System.Text;
using System.Web;4 Y) @7 S$ ~" A- b; W1 z
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;; V7 \! B7 e0 k9 h! O' T$ B' n
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.Configuration;* S, n, l! U" }' t/ d- Y

namespace AJAXBaseHome1 ~9 {* m, e# f
{9 @; i# n( p4 G* l: t3 r
public partial class AutoComplete : System.Web.UI.Page
{$ {% D& a9 B+ g/ z& O5 {! M* A
private static string conString = WebConfigurationManager.ConnectionStrings["myData"].ConnectionString;( L4 y$ T5 \) ]) e& n* W$ E% m
4 q9 C0 I" o6 O( o
prot
图文资讯
广告赞助商