asp.net AutoCompleteExtender的一個簡單例子代碼
更新時間:2009年12月16日 23:08:26 作者:
asp.net AutoCompleteExtender的一個簡單例子代碼
復(fù)制代碼 代碼如下:
<asp:TextBox ID="txtTempScenic" runat="server"></asp:TextBox>
<ajax:AutoCompleteExtender ID="txtTempScenic_AutoCompleteExtender" runat="server" BehaviorID="AutoCompleteEx" DelimiterCharacters="" Enabled="True" ServicePath="~/WebService/AutoComplete.asmx" ServiceMethod="GetScenic" TargetControlID="txtTempScenic" CompletionInterval="500" CompletionSetCount="20" EnableCaching="true" MinimumPrefixLength="1"></ajax:AutoCompleteExtender>
AutoComplete.asmx
復(fù)制代碼 代碼如下:
<%@ WebService Language="C#" CodeBehind="~/App_Code/AutoComplete.cs" Class="AutoComplete" %>
AutoComplete.cs
復(fù)制代碼 代碼如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data;
/// <summary>
///add by ahuinan
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
//若要允許使用 ASP.NET AJAX 從腳本中調(diào)用此 Web 服務(wù),請取消對下行的注釋。
[System.Web.Script.Services.ScriptService]
public class AutoComplete : System.Web.Services.WebService
{
public AutoComplete()
{
//如果使用設(shè)計的組件,請取消注釋以下行
//InitializeComponent();
}
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
//獲得景區(qū)
[WebMethod]
public string[] GetScenic(string prefixText,int count)
{
ET_ERP.BLL.ERP_ScenicArea b_ScenicArea = new ET_ERP.BLL.ERP_ScenicArea();
string strWhere = " SA_Name like '" + prefixText + "%' AND SA_IsDel = 0";
DataSet ds = b_ScenicArea.Select(" top "+count+" SA_Name", strWhere);
count = ds.Tables[0].Rows.Count;
string[] array = new string[count];
for (int i = 0; i < count; i++)
{
array[i] = ds.Tables[0].Rows[i]["SA_Name"].ToString();
}
return array;
}
}
相關(guān)文章
Asp.Net Core2.1前后使用HttpClient的兩種方式
這篇文章主要給大家介紹了關(guān)于Asp.Net Core2.1前后HttpClient的使用方式,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習或者工作具有一定的參考學(xué)習價值,需要的朋友們下面來一起學(xué)習學(xué)習吧2019-03-03
asp.net下經(jīng)典數(shù)據(jù)庫記錄分頁代碼
asp.net下經(jīng)典數(shù)據(jù)庫記錄分頁代碼...2007-04-04
.net core webapi jwt 更為清爽的認證詳解
這篇文章主要介紹了.net core webapi jwt 更為清爽的認證詳解,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2019-05-05
關(guān)于dotnet?替換?ASP.NET?Core?的底層通訊為命名管道的?IPC?庫的問題
這篇文章主要介紹了dotnet?替換?ASP.NET?Core?的底層通訊為命名管道的?IPC?庫,本文給大家介紹的非常詳細,對大家的學(xué)習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2022-02-02
如何將數(shù)據(jù)綁到gridview然后導(dǎo)成excel
這篇文章主要介紹了如何將數(shù)據(jù)綁到gridview然后導(dǎo)成excel,需要的朋友可以參考下2014-02-02
SignalR中豐富多彩的消息推送方式的實現(xiàn)代碼
這篇文章主要介紹了SignalR中豐富多彩的消息推送方式的實現(xiàn)代碼,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習或者工作具有一定的參考學(xué)習價值,需要的朋友們下面隨著小編來一起學(xué)習學(xué)習吧2019-04-04
viewstate和datatable動態(tài)錄入數(shù)據(jù)示例
這篇文章主要介紹了viewstate和datatable動態(tài)錄入數(shù)據(jù)示例,需要的朋友可以參考下2014-02-02
ASP.NET實現(xiàn)讀取Excel內(nèi)容并在Web上顯示
這篇文章主要介紹了ASP.NET實現(xiàn)讀取Excel內(nèi)容并在Web上顯示,很實用的一個技巧,需要的朋友可以參考下2014-08-08

