您好,任何人都可以帮我解决使用c#和Ajax的自动填充文本框代码。我很困惑开发它。
Hello, Can anyone please help me out with the autocomplete textbox code, Which uses c# and Ajax. I'm very much confused of developing it.
推荐答案嗨 你也可以使用这个jQuery jqueryui/demos/autocomplete/ [ ^ ]插件以及网络服务 Hi you can also use this jQuery jqueryui/demos/autocomplete/[^] plugin along with a web service
这是我的aspx文件 This is my aspx File <asp:ImageButton ID="frumgrp_srch_imgbtn" runat="server" ImageUrl="~/images/search.png" /> <br /> <asp:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" TargetControlID="frumgrp_srch_txt" EnableCaching="true" BehaviorID="AutoCompleteCities" ServiceMethod="GetCities" ServicePath="~/AutoComplete.asmx" MinimumPrefixLength="1" CompletionSetCount="5" FirstRowSelected="true"> </asp:AutoCompleteExtender>
这是我的Cs文件
This Is My Cs File
using System; using System; using System.Collections.Generic; using System.Web.Services; using System.Data.SqlClient; using System.Configuration; using System.Data; [WebService] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.Web.Script.Services.ScriptService] public class AutoComplete : WebService { public AutoComplete() { } [WebMethod] public string[] GetCompletionList(string prefixText, int count) { if (count == 0) { count = 10; } DataTable dt = GetRecords(prefixText); List<string> items = new List<string>(count); for (int i = 0; i < dt.Rows.Count; i++) { string strName = dt.Rows[i][0].ToString(); items.Add(strName); } return items.ToArray(); } public DataTable GetRecords(string strName) { string strConn = ConfigurationManager.ConnectionStrings["DatabaseConnectionString"].ConnectionString; SqlConnection con = new SqlConnection(strConn); SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandType = System.Data.CommandType.Text; cmd.Parameters.AddWithValue("@Name", strName); cmd.CommandText = "Select Name from Test where Name like '%'+@Name+'%'"; DataSet objDs = new DataSet(); SqlDataAdapter dAdapter = new SqlDataAdapter(); dAdapter.SelectCommand = cmd; con.Open(); dAdapter.Fill(objDs); con.Close(); return objDs.Tables[0]; } }这是我的asmx文件 <![CDATA [<%@ WebService Language =C#CodeBehind =〜/ App_Code / AutoComplete.cs Class =AutoComplete%> 我无法执行此代码。事实上,它自己没有被调用的web服务。可以任何人帮助。你的帮助对我来说是一个很大的帮助。 急切等待解决方案 提前致谢
This is My asmx File <![CDATA[<%@ WebService Language="C#" CodeBehind="~/App_Code/AutoComplete.cs" Class="AutoComplete" %> I'm not able to execute this code. Infact the webservice it self is not getting called. Can Anyone help. Your help will be a great relief to me. Eagerly Waiting For The Solution Thanks in advance
我知道你已经有了以前所有帖子的答案, 但是这里为您提供了解Ajax自动完成控件的简便方法 视频: www.youtube/watch?v=2i50R-fHHlA [ ^ ] www.youtube/watch?v=nYac4sxChdk [ ^ ] 谢谢 --RA I Know you already got the answer from all previous posts, But here am providing you easy way to know about the Ajax Autocomplete control Videos: www.youtube/watch?v=2i50R-fHHlA[^] www.youtube/watch?v=nYac4sxChdk[^] Thanks --RA
更多推荐
使用ajax和c#在asp.net中自动完成文本框
发布评论