当前位置: 首页 > news >正文

类似百度Google的搜索

界面:



ContractedBlock.gif ExpandedBlockStart.gif Code
//WebService的写法
using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Data;
using System.Data.SqlClient;
/// <summary>
/// WebService 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo 
= WsiProfiles.BasicProfile1_1)]

[System.Web.Script.Services.ScriptService]
public class WebService : System.Web.Services.WebService {

    
public WebService () {

        
//如果使用设计的组件,请取消注释以下行
        
//InitializeComponent();
    }

    [WebMethod]
    
public string[] GetData(string prefixText,int count)
    {
        SqlConnection conn 
= new SqlConnection("server=.;database=Northwind;uid=sa;pwd=;");
        
string Str = "select CompanyName from Customers where CompanyName like '" + prefixText + "%' order by CompanyName ";
        SqlDataAdapter sda 
= new SqlDataAdapter(Str,conn);
        DataSet ds
=new DataSet();
        sda.Fill(ds,
"com");

        
string[] temp=new string[ds.Tables["com"].Rows.Count];
        
for(int i=0;i<ds.Tables["com"].Rows.Count;i++)
        {
            temp[i] 
= ds.Tables["com"].Rows[i]["CompanyName"].ToString();
        }

        
return temp;
    }

}

需要在界面中设定AutoCompleteExtender的属性如图:

设置TargetControlID 为你要控制的控件这里我设置的是TextBox1

这个时候TextBox1就多了个属性

设置ServiceMethod属性为你的WebService 中的方法

设置ServicePath为你的WebService文件的名称

转载于:https://www.cnblogs.com/buzaixian/archive/2009/08/10/1543195.html

相关文章:

  • 世界上最神秘的部门
  • 远程mysql权限
  • 什么行业最有前途 教你如何在IT业拿高薪!
  • linux引导时输入特殊信息的含义
  • CCNA工作指南~
  • 60道Unix试题检验你的水平
  • 通过样式调整input 中password text默认长度
  • 图解入侵过程,黑客未来!
  • django传递嵌套对象给flex前端的方法(原创)
  • 强大的DataGrid组件[8]_内嵌ComboBox动态数据联动——Silverlight学习笔记[16]
  • 在 Ubuntu 下如何用 Mplayer 看影片
  • Java网络编程从入门到精通(33):非阻塞I/O的缓冲区(Buffer)
  • How to map remote network drive
  • GAE研究小组:面向对象与面向过程的工程化理解
  • 亮剑:PHP,我的未来不是梦(9)
  • iOS | NSProxy
  • iOS筛选菜单、分段选择器、导航栏、悬浮窗、转场动画、启动视频等源码
  • JavaScript/HTML5图表开发工具JavaScript Charts v3.19.6发布【附下载】
  • MYSQL 的 IF 函数
  • MySQL的数据类型
  • MySQL用户中的%到底包不包括localhost?
  • PHP 使用 Swoole - TaskWorker 实现异步操作 Mysql
  • Spring技术内幕笔记(2):Spring MVC 与 Web
  • vue 配置sass、scss全局变量
  • Vue组件定义
  • 基于 Ueditor 的现代化编辑器 Neditor 1.5.4 发布
  • 解析 Webpack中import、require、按需加载的执行过程
  • 学习笔记TF060:图像语音结合,看图说话
  • 远离DoS攻击 Windows Server 2016发布DNS政策
  • ​人工智能书单(数学基础篇)
  • $GOPATH/go.mod exists but should not goland
  • (145)光线追踪距离场柔和阴影
  • (23)Linux的软硬连接
  • (52)只出现一次的数字III
  • (android 地图实战开发)3 在地图上显示当前位置和自定义银行位置
  • (汇总)os模块以及shutil模块对文件的操作
  • (论文阅读22/100)Learning a Deep Compact Image Representation for Visual Tracking
  • (一)Neo4j下载安装以及初次使用
  • (一)SpringBoot3---尚硅谷总结
  • (原創) 如何刪除Windows Live Writer留在本機的文章? (Web) (Windows Live Writer)
  • **Java有哪些悲观锁的实现_乐观锁、悲观锁、Redis分布式锁和Zookeeper分布式锁的实现以及流程原理...
  • *++p:p先自+,然后*p,最终为3 ++*p:先*p,即arr[0]=1,然后再++,最终为2 *p++:值为arr[0],即1,该语句执行完毕后,p指向arr[1]
  • . ./ bash dash source 这五种执行shell脚本方式 区别
  • .gitignore文件设置了忽略但不生效
  • .Net - 类的介绍
  • .Net Core和.Net Standard直观理解
  • .NET Micro Framework初体验(二)
  • .NET 读取 JSON格式的数据
  • .net 提取注释生成API文档 帮助文档
  • .net解析传过来的xml_DOM4J解析XML文件
  • .NET框架设计—常被忽视的C#设计技巧
  • @SentinelResource详解
  • [22]. 括号生成
  • [AHOI2009]中国象棋 DP,递推,组合数
  • [BUAA软工]第一次博客作业---阅读《构建之法》