Any example on implementing an AutoComplete TextBox
in ASP.Net which gets data from database, and doesn't use AutoCompleteExtender
from Ajax toolkit, also not using Web/Wcf service for requesting data.
在ASP.Net中实现AutoComplete TextBox的任何示例都是从数据库获取数据,并且不使用Ajax工具包中的AutoCompleteExtender,也不使用Web / Wcf服务来请求数据。
For example with jQuery
and PHP
, i could just use the $.ajax function, passing a url where PHP just returns a JSON
object.
例如,使用jQuery和PHP,我可以使用$ .ajax函数,传递一个url,PHP只返回一个JSON对象。
3 个解决方案
#1
2
If you know how to do it in PHP, the same could be used in asp.net.
You don't need to use a webservice. Just a PageMethod would suffice.
如果您知道如何在PHP中执行此操作,则可以在asp.net中使用相同的内容。您不需要使用Web服务。只需一个PageMethod即可。
Refer: Using jQuery to directly call ASP.NET AJAX page methods
参考:使用jQuery直接调用ASP.NET AJAX页面方法
Since you mention jQuery, this function could return data as required jquery-autocompelete.
由于您提到了jQuery,因此该函数可以根据需要返回数据jquery-autocompelete。
But once you receive the list of suggestions for autocomplete, you could very well write the javascript to show it yourself too.
但是一旦收到自动填充的建议列表,你就可以编写javascript来自己展示它。
#2
1
Very difficult without using any extender
or jquery-autocompelete
Also you will need to create some server side method that will return json
form you server side method after querying the data base.
没有使用任何扩展程序或jquery-autocompelete也很困难你还需要创建一些服务器端方法,它将在查询数据库后从服务器端方法返回json。
#3
1
You can use jQuery-autocomplete and to get data from server you can use Generic Handler (.ashx) to get JSON data from server. In source give path to .ashx page and in handler write JSON data in response stream.
您可以使用jQuery-autocomplete并从服务器获取数据,您可以使用Generic Handler(.ashx)从服务器获取JSON数据。在source中提供.ashx页面的路径,并在处理程序中写入响应流中的JSON数据。
http://jqueryui.com/autocomplete/#remote
http://johnnycoder.com/blog/2008/12/16/httphandler-json-data/
#1
2
If you know how to do it in PHP, the same could be used in asp.net.
You don't need to use a webservice. Just a PageMethod would suffice.
如果您知道如何在PHP中执行此操作,则可以在asp.net中使用相同的内容。您不需要使用Web服务。只需一个PageMethod即可。
Refer: Using jQuery to directly call ASP.NET AJAX page methods
参考:使用jQuery直接调用ASP.NET AJAX页面方法
Since you mention jQuery, this function could return data as required jquery-autocompelete.
由于您提到了jQuery,因此该函数可以根据需要返回数据jquery-autocompelete。
But once you receive the list of suggestions for autocomplete, you could very well write the javascript to show it yourself too.
但是一旦收到自动填充的建议列表,你就可以编写javascript来自己展示它。
#2
1
Very difficult without using any extender
or jquery-autocompelete
Also you will need to create some server side method that will return json
form you server side method after querying the data base.
没有使用任何扩展程序或jquery-autocompelete也很困难你还需要创建一些服务器端方法,它将在查询数据库后从服务器端方法返回json。
#3
1
You can use jQuery-autocomplete and to get data from server you can use Generic Handler (.ashx) to get JSON data from server. In source give path to .ashx page and in handler write JSON data in response stream.
您可以使用jQuery-autocomplete并从服务器获取数据,您可以使用Generic Handler(.ashx)从服务器获取JSON数据。在source中提供.ashx页面的路径,并在处理程序中写入响应流中的JSON数据。
http://jqueryui.com/autocomplete/#remote
http://johnnycoder.com/blog/2008/12/16/httphandler-json-data/