Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the prompt step of the drop-down list when using Ajax Control Toolkit to realize Baidu search?

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

Today, I will talk to you about the steps of the drop-down list when using AjaxControlToolkit to achieve Baidu search. Many people may not know much about it. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.

AjaxControlToolkit is a collection of controls that can automatically supplement text boxes, click on text boxes to pop up calendars, add watermarks and other Ajax effects, including more than 40 controls, such as http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/Default.aspx.

Like Baidu search, according to the input of relevant words by users, it can be easily implemented with the help of AutoCompleteExtender control in AjaxControlToolkit. The results are as follows:

Detailed steps:

One: install AjaxControlToolkit in Vs

AjaxControlToolkit is installed in VS (you need to pay attention to version issues):

Installation method: http://www.asp.net/ajaxlibrary/act.ashx

Prompt for the corresponding version: http://ajaxcontroltoolkit.codeplex.com/

Second: call AutoCompleteExtender in the Web page (Register in advance in the page, the second line of code)

The copy code is as follows:

Three: add Web service WebService.asmx

The copy code is as follows:

Using System

Using System.Collections.Generic

Using System.Data.SqlClient

Using System.Linq

Using System.Web

Using System.Web.Script.Services

Using System.Web.Services

Namespace HTML_editor

{

/ / /

/ Summary description of WebService

/ / /

[WebService (Namespace = "http://tempuri.org/")]

[WebServiceBinding (ConformsTo = WsiProfiles.BasicProfile1_1)]

[System.ComponentModel.ToolboxItem (false)]

/ / to allow this Web service to be called from a script using ASP.NET AJAX, uncomment the following line.

[System.Web.Script.Services.ScriptService]

Public class WebService: System.Web.Services.WebService

{

/ / read matching information from the database

[WebMethod]

[ScriptMethod]

Public string [] GetEnglishName (string prefixText, int count)

{

List suggestions = new List (); / / declare a generic collection

SqlConnection con = new SqlConnection ("server=.;database=Attendance;uid=sa;pwd=;")

Con.Open ()

SqlCommand com = new SqlCommand ("select [EnglishName] from [Employee] where [EnglishName] like'% t% 'order by [EnglishName]", con)

SqlDataReader sdr = com.ExecuteReader ()

While (sdr.Read ())

{

Suggestions.Add (sdr.GetString (0))

}

Sdr.Close ()

Con.Close ()

Return suggestions.ToArray ()

}

/ / generate matching information directly with the method

/ / [WebMethod]

/ / public string [] GetCompleteList (string prefixText, int count)

/ / {

/ / char c1, c2, c3

/ / if (count = = 0)

/ / count = 10

/ / List list = new List (count)

/ / Random rnd = new Random ()

/ / for (int I = 1; I 0)

{

For (int I = 0; I < dt.Rows.Count; iTunes +)

{

Suggestions.Add (dt.Rows [I] [0] .ToString ())

}

}

Return suggestions.ToArray ()

}

}

After reading the above content, do you have a further understanding of the drop-down list prompt steps when using AjaxControlToolkit to achieve Baidu search? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report