JQuery :: Populate An Autocomplete With A LINQ Query?
Nov 6, 2010
I am trying to populate an autocomplete with a LINQ query. The method I am calling returns data, but for some reason the autocomplete that appears on screen is empty. Here is my code.
Apologies for posting the ten billionth jQuery autocomplete question...I'm having trouble with a jQuery UI autocomplete textbox.I'm unsure if I'm doing the right thing client-side to re-populate the autocomplete data source following keystrokes.The javascript in my aspx page is as follows:
I am trying to use j-query autocomplete but i am getting this error: "The name 'txt_UID' does not exist in the current context" ..Â
I am using the code but the example I was following uses a text-box that was outside of the gridview. But my textbox is inside the gridview. Â
How can I make the autocomplete to work a text-box that is inside gridview? Â
-- Here is my javascript <script type="text/javascript"> $(document).ready(function () { $("#<%=txt_UID.ClientID %>").autocomplete({ source: function (request, response) {
[Code] .....
-- and here is my gridview: <asp:GridView ID="GridView1" runat="server" Width="870px" AutoGenerateColumns="False" Font-Names="Arial" Font-Size="11pt" AlternatingRowStyle-BackColor="#C2D69B" HeaderStyle-BackColor="green" ShowFooter="True" CellPadding="4" BackColor="White" BorderColor="#336666"
I'm using jQuery AutoComplete Plugin in ASP.Net as outlined in the article below, so that as a user types in a .Net textbox they get a list of options to choose them. This works fine, but what I need to do now is call a server side function when the user has finished typing or has choosen a value, rather than the user having to submit the value by pressing a button.
I am struggling to create a webservice method using LINQ technology and to populate a dropdown in a form. Here is the Webservice code.
[WebMethod]
public string[] GetAllCountries() { LinqClassesDataContext db = new LinqClassesDataContext(); var q = from c in db.ListContinents()select c; return q.ToList() ; }
And here is the form code behind
protectedvoid Page_Load(object sender, EventArgs e) { WSClass WS = new WSClass();//bool ds = WS.GetAllCountries(); var v = WS.GetAllCountries(); ddlContinent.DataSource = v; ddlContinent.DataBind(); }
On my page I have textbox in which user enters value. When 3 values are entered the autocomplete panel shows.In the panel the names and surnames of all available people are shown bassed on the value user enters. Bellow each name and surname is picture of each "candidate". However images are stored on another server (using https "protection") and some people don't have picture.
onerror="this.onerror=null;this.src='../Pics/Errors/NoPic.jpg'" into <img> tags in Web Handler.
i have using jquery for autocompelete option and iam using ashx file, i have 2textbox, i need to show diffrent search record in the text box, iam using 2 ashx file to show the value using jquery, i want to user single ashx file instead of iam using 2 ashx handle filer can use switch case to handle this , i want to use 7textbox all textbox i need to do autosearch, how to handle this senario using jquery and ashx handler file
clsquery.updatetablestring = "select top 2 Cont_number from ASPrearrival_list where Cont_number"; clsquery.updatetablestring = "select top 2 custid,custname from ASCustomer where custname"; // this is my auto search iam using 2 handler file , i wants only one handler instead of 2handler <script type="text/javascript" src="jquery.autocomplete.js"></script> <script type="text/javascript"> $(document).ready(function() { $("#<%=txtcontno.ClientID%>").autocomplete("Handler1.ashx"); $("#<%=txtcname.ClientID%>").autocomplete("Handler.ashx"); } ); handler ashx file <%@ WebHandler Language="C#" %> using System; using System.Web; using System.Data.SqlClient; using ASbusinesslogic; public class Handler : IHttpHandler { public void ProcessRequest(HttpContext context) { string firstname = context.Request.QueryString["q"]; string sql = clsquery.updatetablestring; sql = clsquery.updatetablestring+" "+"Like"+" '"+ firstname +"%'"; //string sql = "select top 2 mlid,mloname from ASlinermaster where mloname like '" + firstname + "%'"; using (SqlConnection connection = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"].ToString())) using (SqlCommand command = new SqlCommand(sql, connection)) { connection.Open(); using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { context.Response.Write(reader.GetString(1)+ "-"+ reader.GetValue(0) + Environment.NewLine); } } } } public bool IsReusable { get { return false; } } } handler1 <%@ WebHandler Language="C#" %> using System; using System.Web; using System.Data.SqlClient; using ASbusinesslogic; public class Handler1 : IHttpHandler { public void ProcessRequest(HttpContext context) { string firstname = context.Request.QueryString["q"]; string sql = clsquery.updatetablestring + " " + "like '" + firstname + "%' "; using (SqlConnection connection = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"].ToString())) using (SqlCommand command = new SqlCommand(sql, connection)) { connection.Open(); using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { context.Response.Write(reader.GetString(0) + Environment.NewLine); } } } } public bool IsReusable { get { return false; } } }
I have this menu which has z-index of 600.I also use autocomplete, and I set the zIndex option to 700, I also tried setting the z-index in the css file, but no matter what i do, the ul list the autocomplete script generats always has z-index of 1.
this is what i see when i "inspect element" using chrome(the results ul):
[Code]....
no css alteration will help there, since its written into the style attribute of the ul element, and the zIndex option of autocomplete seems to do nothing also.for now, i can handle it by simply setting the z-index of the menu to 0, but thats a realy dirty workaround since i do want to control the z index of the autocomplete results ul.
I built a modal dialog using the ModalPopupExtender from the AjaxControlToolkit. In that dialog, I'm trying to use the jQuery Autocomplete feature on a textbox. The values for the autocompletion are fetched from a webservice.I can see that the webservice is returning a result set, and I can see that being picked up in the Autocomplete code. However, the list is not displayed to the user to pick from.I thought this might be a z-Index issue, so I specified 'z-index: 9999 !important;' in my stylesheet. But that doesn't make a difference.
I've build a linq query.But i want a random selection so its not always ID : 1,2,3,4,5,6 How can i randomize this var? I like to bind it to a repeater.//TagCloud:
Random rand = new Random(); var tc1 = from i in JumpTide.cms.menu.GetMenuItems(32) select new
I'm using a JQuery plugin [URL] to add auto-completion to a "city" textfield. The component calls an ASP.NET page that simply loads an array of all possible city values (>8000) and then iterates that array returning those that start with the text the user has so far entered.
The thing is, it's pretty slow in real use. It lags behind what the user types to the extent that most of the time the user probably won't notice that it's there.
So, my question is, how can I speed it up?
I had thought that an array would be a better way to go than putting the data in a database and having to hit that multiple times. Do others agree that having this information hard-coded is the way to go given that it's not at all volatile and needs to be all about speed of return?
If so, what would you look at to improve the speed of performance? Should I be caching the data on application start and accessing it from memory? Would I be better off instead with multiple arrays, each containing values starting with a particular letter so I can go straight to the relevant one and thus iterate a much smaller array? Or am I missing a much more obvious way to go about this?
I am facing a big problem with simple linq query.. I am using EF 4.0..
I am trying to take all the records from a table using a linq query:
var result = context.tablename.select(x=>x);
This results in less rows than the normal sql query which is select * from tablename;
This table has more than 5 tables as child objects (foreign key relations: one to one and one to many etc)..
This result variable after executing that linq statement returns records with all child object values without doing a include statement.. I don't know is it a default behavior of EF 4.0 . I tried this statement in linqpad also..but there is no use... But interesting thing is if I do a join on the same table with another one table is working same is sql inner join and count is same..but I don't know why is it acting differently with that table only.. Is it doing inner joins with all child tables before returning the all records of that parent table?
So the BlogPostTags table only contains 2 fields, BlogPostID and TagID.
When i run the query above i get 3 results back. Same blogpost 3 times but with 1 tag in each. It should return 1 post with 3 tags. The problem lies in the Tags query above.
An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
am using Autocomplete Jquery from the following URL:[URL]I am making my project in MVC 3.0 (Razor) In this I am displaying list of names from the database and its running fine.Now I want to show this whole list in the div according to my project requirement.
I have a dropdown in my CreateDocumentTemplate ciew <%=Html.DropDownList("Part", (SelectList)ViewData["Part"])%> which is populated from database. I want to this dropdown to be autocomplete. How can I acoomplish this?
in my webapplication, I'm using asp.net dropdownlists, that are filled with data (text & id) through ObjectDatasources.
I'd like to use the jquery autocomplete on the dropdownlists, but I fail to find any good example for it, unless examples that are using http handlers or webservices, which I'd like to avoid.