博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
jQuery:SP.NET Autocomplete Textbox Using jQuery, JSON and AJAX
阅读量:5045 次
发布时间:2019-06-12

本文共 4707 字,大约阅读时间需要 15 分钟。

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="jQueryAutocomplete.aspx.cs" Inherits="VipWinValidation.jQueryAutocomplete" %>
编辑管理员
Country :

  

///     /// $codebehindclassname$ 的摘要说明    ///     ///     [WebService(Namespace = "http://tempuri.org/")]    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]    public class LoadCountry : IHttpHandler    {        ///         ///         ///         ///         public void ProcessRequest(HttpContext context)        {            HttpRequest request = context.Request;            HttpResponse response = context.Response;            System.Collections.Specialized.NameValueCollection forms = context.Request.Form;            string strOperation = forms.Get("term"); //            List
li = Country(strOperation); JavaScriptSerializer JS = new JavaScriptSerializer(); string sf = JS.Serialize(li); context.Response.Write(sf); } ///
/// /// ///
///
private List
Country(string input) { //Get the countries list from database, for this example I am creating sample output //return GetCountriesfromDB(input); List
li = new List
(); foreach (string s in GetCountries()) { string st = s.ToLower(); if (st.Contains(input.ToLower())) { li.Add(s); } } //Linq //return GetCountries().FindAll(item => item.ToLower().Contains(input.ToLower())); return li; } ///
/// /// ///
private List
GetCountries() { List
CountryInformation = new List
(); CountryInformation.Add("India"); CountryInformation.Add("United States"); CountryInformation.Add("United Kingdom"); CountryInformation.Add("Canada"); CountryInformation.Add("South Korea"); CountryInformation.Add("France"); CountryInformation.Add("Mexico"); CountryInformation.Add("Russia"); CountryInformation.Add("Australia"); CountryInformation.Add("Turkey"); CountryInformation.Add("Kenya"); CountryInformation.Add("New Zealand"); CountryInformation.Add("涂聚文"); CountryInformation.Add("涂年生"); CountryInformation.Add("江西省"); CountryInformation.Add("江苏省"); CountryInformation.Add("浙江省"); return CountryInformation; } ///
/// /// public bool IsReusable { get { return false; } } }

  .net 4.0

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="jQueryAutocomplete.aspx.cs" Inherits="DuCms.Web.jQueryAutocomplete" %>
编辑管理员
Country :

  

using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.Services;namespace DuCms.Web{    ///     ///     ///     public partial class jQueryAutocomplete : System.Web.UI.Page    {        ///         ///         ///         ///         ///         protected void Page_Load(object sender, EventArgs e)        {        }        [WebMethod]        public static List
LoadCountry(string input) { List
li = new List
(); //Get the countries list from database, for this example I am creating sample output //return GetCountriesfromDB(input); li = GetCountries().FindAll(item => item.ToLower().Contains(input.ToLower())); return li; } ///
/// /// ///
public static List
GetCountries() { List
CountryInformation = new List
(); CountryInformation.Add("India"); CountryInformation.Add("United States"); CountryInformation.Add("United Kingdom"); CountryInformation.Add("Canada"); CountryInformation.Add("South Korea"); CountryInformation.Add("France"); CountryInformation.Add("Mexico"); CountryInformation.Add("Russia"); CountryInformation.Add("Australia"); CountryInformation.Add("Turkey"); CountryInformation.Add("Kenya"); CountryInformation.Add("New Zealand"); CountryInformation.Add("涂聚文"); CountryInformation.Add("涂年生"); CountryInformation.Add("江西省"); CountryInformation.Add("江苏省"); CountryInformation.Add("浙江省"); return CountryInformation; } }}

  

转载于:https://www.cnblogs.com/geovindu/p/8405259.html

你可能感兴趣的文章
在ns2.35中添加myevalvid框架
查看>>
【贪心+DFS】D. Field expansion
查看>>
为什么要使用href=”javascript:void(0);”
查看>>
二进制文件的查看和编辑
查看>>
oracle正则表达式
查看>>
twitter——数据连接
查看>>
Maven创建项目时出现Generating project in Interactive mode就一直卡住的解决方案
查看>>
angular框架的面试题集锦
查看>>
JAVA泛型使用方法总结
查看>>
HTML_记录2
查看>>
ECSHOP中ajax的调用原理
查看>>
新浪微博API OAuth1 Python3客户端
查看>>
MongoDB—— 写操作 Core MongoDB Operations (CRUD)
查看>>
18_simpleadapter和ArrayAdapter总结
查看>>
盒子模型的弹性盒
查看>>
嫁给程序员1314的好处
查看>>
【高精度&想法题】Count the Even Integers @ICPC2017HongKong/upcexam5563#Java
查看>>
蓝桥杯-猜年龄-java
查看>>
JavaScript Window
查看>>
一些自己容易搞错的java题目(陆续更新)
查看>>