I am currently working with ac # asp.net usercontrol where I need a functional autocomplete.
The script sees as if it wants to walk, as you can see; The progress bar is spin, but it always comes back to 'error'
. I'm not sure what to do from here I followed at least 5 different tutorials to do this work; Code found code; But it does not seem like when everyone is said and done. What am I missing? If I need any suggestions then I would greatly appreciate it.
If more information is needed then let me know, but the whole code can be found below.
HTML / Javascript
& lt; % @ Control language = "C #" autoAventWheel = "True" codebahind = "Search Textbox .ascx.cs" Inheritance = "Stegging Application.Search Search Tabbox"% " & Lt; Link href = "../ css / styleCustomPages.css" rel = "stylesheet" /> & Lt; Link href = "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/themes/base/jquery-ui.css" rel = "stylesheet" type = "text / css" /> & Lt; Script type = "text / javascript" src = "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" src = "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js" & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" & gt; $ (Document) .ready (function () {SearchText ();}); Function SearchText () {$ ("autosuggest.") Autocomplete ({source: function (request, response) {$ .ajax ({type: "post", contentType: "application / json; charset = utf-8 "," Search_Textbox.aspx / GetAutoCompleteData ", data:" {'searchText': '' + document.getElementById ('txtSearch') value +. "'}", Datatype: "json", success: function (data } {Response (data.d);}, error: work (result) {warning ('error');}})}}})}}
C # code behind
using the system; System.Collections Using Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; System.Data Using .sqlClient; using System.Web.Services; using System.Web.Script.Services; Namespace StagingApp Search {public partial category Search_Textbox: System.Web.UI.UserControl {#region Declarations static string dbSearch = "db string"; #endrian Protected Zero Page_Load (Object Sender, EventAGRS E) {} # Digit Methods and Functions [WebMath, Scriptmath] Public Static List & lt; String & gt; GetAutoCompleteData (string search text) {list & lt; String & gt; Results = New list & lt; String & gt; (); Using (SqlConnection Thief = New SqlConnection (dbSearch)) {Using (SqlCommand cmd = New SqlCommand ("Select Top 1000 [SEARCHTERM] from [Search]. [Dbo]. [Cache] where AutoCompleteTerm = 0 And @SearchText + '%'; ", Con) like SEARCHTERM) {con.Open (); Cmd.Parameters.AddWithValue ("@ SearchText", searchText); SqlDataReader dr = cmd.ExecuteReader (); While (Dr. Reid ()) {result.Add (dr ["SearchTerm"]. ToString ()); } Return results; }}}}}}
cmd.Parameters.AddWithValue ("@ SearchText", search text);
Variable search text is not present because:
Your function begins with:
public static list & lt ; String & gt; GetAutoCompleteData (string user name)
should be:
public static list & lt; String & gt; GetAutoCompleteData (String Search Text)
You forgot to search for usernames Text.
Comments
Post a Comment