简体   繁体   中英

Dynamically changing textbox value in asp.net

I want to design a textbox most likely like what Google search textbox provides where it can receive data from user and check the database and suggest few examples. How can dynamically change the textbox value as the user is typing in. There are Event attribute in visual studio but it works in a way of refreshing page by clicking somewhere out of textbox! so it doesn't work properly.

Best bet is to use the AutoComplete control provided by the ASP.NET Ajax Control Toolkit. See an example here: http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/AutoComplete/AutoComplete.aspx

Basically, setup a webservice which will be polled via Ajax. Your service will take the text provided by the user, you'll do some lookup/search in your database, then return the matches back. The Ajax JavaScript then updates the textbox accordingly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM