代码语言
.
CSharp
.
JS
Java
Asp.Net
C
MSSQL
PHP
Css
PLSQL
Python
Shell
EBS
ASP
Perl
ObjC
VB.Net
VBS
MYSQL
GO
Delphi
AS
DB2
Domino
Rails
ActionScript
Scala
代码分类
文件
系统
字符串
数据库
网络相关
图形/GUI
多媒体
算法
游戏
Jquery
Extjs
Android
HTML5
菜单
网页交互
WinForm
控件
企业应用
安全与加密
脚本/批处理
开放平台
其它
【
Asp.Net
】
Ajax 自动提示 AutoCompleteExtender
作者:
曾祥展
/ 发布于
2011/3/15
/
967
<div> <font color="#ff8000" size="4">html:</font> <pre class="code"><span style="background: rgb(255,238,98)"><%<span style="color: blue">@ </span><span style="color: rgb(163,21,21)">Page </span><span style="color: red">Language</span><span style="color: blue">="C#" </span><span style="color: red">AutoEventWireup</span><span style="color: blue">="true" </span><span style="color: red">CodeFile</span><span style="color: blue">="Default.aspx.cs" </span><span style="color: red">Inherits</span><span style="color: blue">="_Default" </span><span style="background: rgb(255,238,98)">%> <%<span style="color: blue">@ </span><span style="color: rgb(163,21,21)">Register </span><span style="color: red">Assembly</span><span style="color: blue">="AjaxControlToolkit" </span><span style="color: red">Namespace</span><span style="color: blue">="AjaxControlToolkit" </span><span style="color: red">TagPrefix</span><span style="color: blue">="cc1" </span><span style="background: rgb(255,238,98)">%> </span><span style="color: blue"><!</span><span style="color: rgb(163,21,21)">DOCTYPE </span><span style="color: red">html PUBLIC </span><span style="color: blue">"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <</span><span style="color: rgb(163,21,21)">html </span><span style="color: red">xmlns</span><span style="color: blue">="http://www.w3.org/1999/xhtml"> <</span><span style="color: rgb(163,21,21)">head </span><span style="color: red">runat</span><span style="color: blue">="server"> <</span><span style="color: rgb(163,21,21)">title</span><span style="color: blue">></</span><span style="color: rgb(163,21,21)">title</span><span style="color: blue">> </</span><span style="color: rgb(163,21,21)">head</span><span style="color: blue">> <</span><span style="color: rgb(163,21,21)">body</span><span style="color: blue">> <</span><span style="color: rgb(163,21,21)">form </span><span style="color: red">id</span><span style="color: blue">="form1" </span><span style="color: red">runat</span><span style="color: blue">="server"> <</span><span style="color: rgb(163,21,21)">div</span><span style="color: blue">> <</span><span style="color: rgb(163,21,21)">asp</span><span style="color: blue">:</span><span style="color: rgb(163,21,21)">ScriptManager </span><span style="color: red">ID</span><span style="color: blue">="ScriptManager1" </span><span style="color: red">runat</span><span style="color: blue">="server"> </</span><span style="color: rgb(163,21,21)">asp</span><span style="color: blue">:</span><span style="color: rgb(163,21,21)">ScriptManager</span><span style="color: blue">> <</span><span style="color: rgb(163,21,21)">div</span><span style="color: blue">> <</span><span style="color: rgb(163,21,21)">asp</span><span style="color: blue">:</span><span style="color: rgb(163,21,21)">TextBox </span><span style="color: red">ID</span><span style="color: blue">="TextBox1" </span><span style="color: red">runat</span><span style="color: blue">="server"></</span><span style="color: rgb(163,21,21)">asp</span><span style="color: blue">:</span><span style="color: rgb(163,21,21)">TextBox</span><span style="color: blue">> <</span><span style="color: rgb(163,21,21)">cc1</span><span style="color: blue">:</span><span style="color: rgb(163,21,21)">AutoCompleteExtender </span><span style="color: red">ID</span><span style="color: blue">="AutoCompleteExtender1" </span><span style="color: red">runat</span><span style="color: blue">="server" </span><span style="color: red">TargetControlID</span><span style="color: blue">="TextBox1" </span><span style="color: red">MinimumPrefixLength</span><span style="color: blue">="1" </span><span style="color: red">ServiceMethod</span><span style="color: blue">="GetProductName" </span><span style="color: red">ServicePath</span><span style="color: blue">="WebService.asmx"> </</span><span style="color: rgb(163,21,21)">cc1</span><span style="color: blue">:</span><span style="color: rgb(163,21,21)">AutoCompleteExtender</span><span style="color: blue">> </</span><span style="color: rgb(163,21,21)">div</span><span style="color: blue">> </</span><span style="color: rgb(163,21,21)">div</span><span style="color: blue">> </</span><span style="color: rgb(163,21,21)">form</span><span style="color: blue">> </</span><span style="color: rgb(163,21,21)">body</span><span style="color: blue">> </</span><span style="color: rgb(163,21,21)">html</span><span style="color: blue">> </span></pre> <font color="#ff8000" size="4">WebService.cs:</font> <pre class="code"><span style="color: blue">using </span>System; <span style="color: blue">using </span>System.Collections.Generic; <span style="color: blue">using </span>System.Linq; <span style="color: blue">using </span>System.Web; <span style="color: blue">using </span>System.Web.Services; <span style="color: blue">using </span>System.Data.SqlClient; <span style="color: blue">using </span>System.Data; <span style="color: blue">using </span>System.Web.Script.Services;<span style="color: green">//关键程序集引用 </span><span style="color: gray">/// <summary> ///</span><span style="color: green">WebService 的摘要说明 </span><span style="color: gray">/// </summary> </span>[<span style="color: rgb(43,145,175)">WebService</span>(Namespace = <span style="color: rgb(163,21,21)">"http://tempuri.org/"</span>)] [<span style="color: rgb(43,145,175)">WebServiceBinding</span>(ConformsTo = <span style="color: rgb(43,145,175)">WsiProfiles</span>.BasicProfile1_1)] <span style="color: green">//若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。 </span>[System.Web.Script.Services.<span style="color: rgb(43,145,175)">ScriptService</span>] <span style="color: blue">public class </span><span style="color: rgb(43,145,175)">WebService </span>: System.Web.Services.<span style="color: rgb(43,145,175)">WebService </span>{ <span style="color: blue">public </span>WebService () { <span style="color: green">//如果使用设计的组件,请取消注释以下行 //InitializeComponent(); </span>} [<span style="color: rgb(43,145,175)">WebMethod</span>] [<span style="color: rgb(43,145,175)">ScriptMethod</span>] <span style="color: blue">public string</span>[] GetProductName(<span style="color: blue">string </span>prefixText, <span style="color: blue">int </span>count) { <span style="color: rgb(43,145,175)">List</span><<span style="color: blue">string</span>> suggestions = <span style="color: blue">new </span><span style="color: rgb(43,145,175)">List</span><<span style="color: blue">string</span>>();<span style="color: green">//声明一泛型集合 </span><span style="color: rgb(43,145,175)">SqlConnection </span>con = <span style="color: blue">new </span><span style="color: rgb(43,145,175)">SqlConnection</span>(<span style="color: rgb(163,21,21)">"server=JUQI;database=NorthWind;uid=sa;pwd=sa;"</span>); con.Open(); <span style="color: rgb(43,145,175)">SqlCommand </span>com = <span style="color: blue">new </span><span style="color: rgb(43,145,175)">SqlCommand</span>(<span style="color: rgb(163,21,21)">"select distinct productname from Products where productname like @prefixname order by productname"</span>, con); com.Parameters.Add(<span style="color: rgb(163,21,21)">"@prefixname"</span>, <span style="color: rgb(43,145,175)">SqlDbType</span>.NVarChar).Value = prefixText + <span style="color: rgb(163,21,21)">"%"</span>; <span style="color: rgb(43,145,175)">SqlDataReader </span>sdr = com.ExecuteReader(); <span style="color: blue">while </span>(sdr.Read()) { suggestions.Add(sdr.GetString(0)); } sdr.Close(); con.Close(); <span style="color: blue">return </span>suggestions.ToArray(); } }</pre> </div>
试试其它关键字
AutoCompleteExtender
同语言下
.
gzip压缩
.
实现http多线程断点续传下载文件
.
实现多线程断点续传下载大文件
.
生成字符串的 CheckSum
.
根据 UserAgent 获取浏览器的类型和版本
.
根据 Agent 判断是否是智能手机
.
隐藏手机号中间四位为*方法
.
合并图片(二维码和其他图片合并)
.
ASP.NET CORE中判断是否移动端打开网页
.
ASP.NET(C#)实现页面计时(定时)自动跳转
可能有用的
.
C#实现的html内容截取
.
List 切割成几份 工具类
.
SQL查询 多列合并成一行用逗号隔开
.
一行一行读取txt的内容
.
C#动态修改文件夹名称(FSO实现,不移动文件)
.
c# 移动文件或文件夹
.
c#图片添加水印
.
Java PDF转换成图片并输出给前台展示
.
网站后台修改图片尺寸代码
.
处理大图片在缩略图时的展示
曾祥展
贡献的其它代码
(
13
)
.
C#加密算法汇总
.
根据不同的条件查询不同的表
.
有小时、分钟,求平均工作时间
.
PHP操作Sql Server数据库时使用事务的示例
.
SQL Server 多条件查询
.
Ajax 自动提示 AutoCompleteExtender
.
监视MySQL 查询缓存性能
.
看看当前缓存中有多少条信息
.
仿Google自动提示 SearchSuggess
.
GridView 导出到 Word/Excel/PDF/CSV
Copyright © 2004 - 2024 dezai.cn. All Rights Reserved
站长博客
粤ICP备13059550号-3