使用C#在ASP.NET中使用文本框搜索AJax [英] Searching through AJax using Textbox in asp.net, C#
本文介绍了使用C#在ASP.NET中使用文本框搜索AJax的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
先生,我是桑迪亚,
任何人都可以发送代码和设计页面以使用AJAX搜索数据.
我需要像Google一样进行搜索.
顺便说一句,我需要从gridview搜索数据.当我输入一个字母时,它应该显示所有的细节.就像GOOGLE搜索一样.我还需要在文本框内添加水印.
请任何人向我发送设计和代码页.
非常感谢您,
Sir , This is Sandhya,
Please can anyone send the code and design pages for searching the data using AJAX.
i need to search like google.
By the way, i need to search the data from gridview. when i type one letter it should show all the details of that. JUST LIKE GOOGLE Search. i need water mark also inside the textbox.
Please anyone send me the design and code page.
Thank u so much sirs,
推荐答案
[WebMethod]
public static List<string> GetAutoCompleteData(string username)
{
List<string> result = new List<string>();
using (SqlConnection con = new SqlConnection("Data Source=SureshDasari;Integrated Security=true;Initial Catalog=MySampleDB"))
{
using (SqlCommand cmd = new SqlCommand("select DISTINCT UserName from UserInformation where UserName LIKE '%'+@SearchText+'%'", con))
{
con.Open();
cmd.Parameters.AddWithValue("@SearchText", username);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
result.Add(dr["UserName"].ToString());
}
return result;
}
引用此链接
http://www.asp.net/ajaxlibrary/act_AutoComplete_Simple.ashx
Refer this link
http://www.asp.net/ajaxlibrary/act_AutoComplete_Simple.ashx
You must have create WebService for this.
此解决方案使用WebService,Entity Framework,Jquery,JqueryUI
查看页面
This solution uses WebService, Entity Framework , Jquery, JqueryUI
View Page
<html lang="en">
<head>
<title>jQuery UI Autocomplete</title>
<link rel="stylesheet"
href="@Url.Content("~/Content/themes/base/jquery.ui.all.css")">
<script src="@Url.Content("~/Scripts/jquery-1.5.2.min.js")"
type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery-ui-1.8.16.min.js")"
type="text/javascript"></script>
<script
这篇关于使用C#在ASP.NET中使用文本框搜索AJax的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文