简体   繁体   English

在ASP.NET中动态更改文本框值

[英]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. 我想设计一个文本框,就像Google搜索文本框所提供的那样,它可以在其中接收用户的数据并检查数据库,并提供一些示例。 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! 如何在用户键入内容时动态更改文本框的值。VisualStudio中具有Event属性,但它可以通过单击文本框之外的某个位置来刷新页面的方式起作用! so it doesn't work properly. 因此无法正常工作。

Best bet is to use the AutoComplete control provided by the ASP.NET Ajax Control Toolkit. 最好的选择是使用ASP.NET Ajax控件工具包提供的AutoComplete控件。 See an example here: http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/AutoComplete/AutoComplete.aspx 在此处查看示例: http : //www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/AutoComplete/AutoComplete.aspx

Basically, setup a webservice which will be polled via Ajax. 基本上,设置一个将通过Ajax进行轮询的Web服务。 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. 然后,Ajax JavaScript将相应地更新文本框。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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