.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

jQuery UI Autocomplete, Web Services and JSON

Posted By:      Posted Date: August 29, 2010    Points: 0   Category :ASP.Net
Hi guys, this is my first post, I´m desperate after wasting 2 days in google and reading forums ans sites. I can´t make it work. I just want to provide the name of cities to show in the autocomplete plugin. Let´s go part by part:WEB SERVICE: I use the Json.Net component to serialize a datasetpublic string ConsultTable(string data) { SqlConnection connection = new SqlConnection(WebConfigurationManager.ConnectionStrings["SqlServerConnection"].ToString()); SqlCommand command = new SqlCommand("SELECT name FROM cities",connection); connection.Open(); DataSet dataset = ToDataSet(command.ExecuteReader()); Newtonsoft.Json.JsonSerializer json = new Newtonsoft.Json.JsonSerializer(); json.NullValueHandling = NullValueHandling.Ignore; json.ObjectCreationHandling = Newtonsoft.Json.ObjectCreationHandling.Replace; json.MissingMemberHandling = Newtonsoft.Json.MissingMemberHandling.Ignore; json.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; json.Converters.Add(new DataSetConverter()); StringWriter sw = new StringWriter(); Newtonsoft.Json.JsonTextWriter writer = new JsonTextWriter(sw); writer.Formatting = Formatting.None; writer.QuoteChar = '"'; json.Se

View Complete Post

More Related Resource Links

jquery autocomplete multiple values


i got some samples and i did autocomplete using jquery , its working well for single input values

but i need to pass multiples values after one by one in the textbox. Is it possible to pass multiple

values in the textbox for autocomplete in jquery in asp.net?


build repository from SQL 2005? for a Linq, Jquery autocomplete



  I have the a question am going about his correctly I have a database for categories, it has many fields and about 4000 records,  but with a Jquery autocomplete needing speed and the fact that I only need to return a key and category name. I did the following:  (oh just to note, MVC2, Ajax project)


    public class categorySearch
        public Guid Category_GUID { get; set; }
        public string Category_Name { get; set; }


and now for the repository

    public class categoryRepository
        internal List<categorySearch> FindCategory(string searchText, int maxResults)
            List<categorySearch> category = new List<categorySearch>();
            dbWebEntities storedb = new dbWebEntities(); 

            var getcat = storedb.Categories.ToList();

            foreach (var item in getcat)
                category.Add(new categorySearch { Category_GUID = item.Cat_GUID, Category_Name = item.Category_Name});

            var result = from c in category
                         where c.Category_Name.Contains(searchText)
                         orderby c.Category_Name

Writing Data to database with jQuery Forms, ASMX Webservice, & JSON - help!



Can someone point me in the right direction on how to submit data from a jQuery form to a ASMX webservice? I have gotten everything on the form ready to be submitted to the database and now I am stuck on how to send it over using $.ajax(). Everything I have read tells me how to get data from a webservice and display it with jQuery, but not the other direction nor how to access the json data within the within the webservice service(similar to a Request.Form approach with ASP.NET forms).

In other words: 

1. What do I need to do to my webservice to make sure it can receive data from the jQuery form. 

2. What do I need to do in jQuery to receive an acknowledgement the save on the server side was successful. 

I can explain more if need be, but if there is a comprehensive tutorial on not only reading, but also WRITING data with jQuery, JSON, etc. I would love to get pointed in that direction. 

jquery autocomplete selected value



Iam using jquery autocomplete to search data and i have button to get the detail value of employee and

display in label , what i need is that , i don't want to put button to get detail , instead i need to select the from\

auto search and press enter key  and show the detail in the lablel example(empname,address, emailid).

Looking forward valuable suggestions

Can I write a wcf endpoint to communicate with JSON from Jquery on page?

Hi Guys,I need to be able to expose information to a page, and I need to write the information in xml on my webserver which will be dynamically created from the database. I need to use json to pass the data from the screen back to the server two way communication xms back and forth. Is it actually any good using a wcf endpoint to serve the json back to the page and use query with wcf? Is this possible?Or is it easier to use standard pages .aspx and just do a call to a url and get the json with jquery....We will probably want to send this information to other locations at some point in the future too....Cheers,Pete

ashx handler using jquery autocomplete

Hi, 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 filercan use switch case to handle this , i want to use 7textbox  all textbox i need to do autosearch, how to handlethis senario using jquery and ashx handler file below the code this is my codebehind query 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%>&q

Web Services with JSON output in VB

How do you write a web services with JSON output in vb?  I see a lot of examples of this in C# but i don't know C#.  Also, is there a way to put data in my SQL database through a web services?

Asynchronous Web Services, jQuery or .NET (BeginInvoke) Calls?



I have been moving my application to be more AJAX-based.  Currently I have a web service call where I use jQuery to gather some textbox (string) and checkbox (boolean) results and pass it to a web service.  Everything works really well, the response time is super quick.  The only downside that I can see to this is

1) you need to use jQuery, which will add to the user's download time - this doesn't really affect my application too much because I am using jQuery throughout the site

2) users can see the code and potentially try to hack the web service because they know where it is

I am most concerned with #2.  I've been reading a lot about .NET web service calls, using IAsyncResult, http://msdn.microsoft.com/en-us/library/2e08f6yc.aspx, and I am beginning to understand the 4 methods available in this article.  However, is there extra bloat using this way compared to the jQuery web service call?

If there isn't that much bloat or lag time using this method, I'd like to convert my application.  Which one of these 4 methods is best in a scenario where I am just returning a small string value?  The 4 methods in the article are

  • to wait for EndInvoke itself, which from what I read is not recom

JQuery and web services


I am currently using JQuery to post to action methods in my MVC app.  The methods are quite complicated and since I only know the basics of Javascript and JQuery, if I wanted to use JQuery to make a client side call, would I be able to make a call to a web service to do this?  I am new to all these technologies so not sure about how posting from JQuery to web services etc works! 

MVC Json and Jquery with dropdownlist


 Dear all,

I want to do like below:

I have three dropdownlist:

- test

- test1

- test2

and i have two textbox

 - txtname

- txtsex

when i click on test dropdown list i want to diplay data in test1 dropdownlist and display in txtname and txtsex too, how can i do by using mvc json and jquery ?

how to save and retrive date in database using jquery ajex asp.net ,JSOn,XML,HTML


how to save and retrive  date in database using  jquery ajex asp.net ,JSOn,XML

JQuery Autocomplete Call WCF Service Method


I am trying to use the below code to call a wcf service method for Autocomplete functionality in a TextBox.  I have written the following query:

$(document).ready(function () {
            $("#<%= txtCompany.ClientID %>").autocomplete(http://localhost/PieScore/PieScore.Application.Services/EmployeeService.svc/GetTestCompanyList, {
                dataType: 'json',
                parse: function (data) {
                    var items = data.d;
                    var parsed = [];
                    for (var i = 0; i < items.length; i++)
                        parsed[i] = {

jquery ajax - bind json to dropdownlist


I'm using jquery ajax to populate a dropdown list to avoid page refresh via a webmethod.

My webmethod returns a json string. My question is how can i bind this to my asp.net dropdownlist?

See below for jquery code:

function getTeamid() {
        var teamid = $(".ccTeam").val();            
            type: "POST",
            url: "NewJob.aspx/sayHello",
            data: "{val:" + teamid + "}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(msg) {
                error: AjaxFailed


    function AjaxSucceeded(result) {
    function AjaxFailed(result) {
          alert(result.status + ' ' + result.statusText);

See below for webmethod code:

        public static string sayHello(string val)
            DataTable dt = dbTeam.getJobTypesByTeamid(val);
            return Intranet.Core.Util.GetJSONString(dt);            


jquery ajax json



I've finally got my dropdowns populating via jquery,ajax and json (via page methods). It works fine, until I submit the page I get error shown below. What's the best way of fixing this?

Part of me is tempted to just install asp.net ajax/update panels and use this, however, I really want to avoid this as I want to stick with jquery ajax and json especially as I've spent time learning this. thanks.

Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page.  For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.  If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation. 


jquery autocomplete not firing




iam using jquery auto complete for ,but its not firing handlerold.ashx file,

pls give valuable suggestions

script type="text/javascript">
//      $(document).ready(function()
//      {
        $("#<%=txtguages.ClientID%>").autocomplete('Handlerold.ashx',{minChars:1,extraParams:{"param1":"1"}}).result(function (event, data, formatted) {
        if (data) {
            alert('Value: '+ data[1]);
            $("#<%= Hdnguages.ClientID %>").val(data[1]);
        else {
            $("#<%= Hdnguages.ClientID %>").val('-1');

handlerold.ashx code below

<%@ WebHandler Language="C#" %>

using System;
using System.Web;
using vdatalayer;
using System.Data.SqlClient;
using S

jquery autocomplete



has anyone ever tried jquery multiple autocomplete (http://jqueryui.com/demos/autocomplete/#option-source ). How do I filter itbased on the first char?so instead of '%_%' it will be '_%'


jquery autocomplete does not show


Hi all

im trying to get a autocomplete with jquery

this is what i  have:


<%@ WebHandler Language="VB" Class="cityAutoComplete" %>

Imports System
Imports System.Web
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.Text

Public Class cityAutoComplete : Implements IHttpHandler
    Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
        Dim clDb As New myClassDb
        Dim prefixText As String = context.Request.QueryString("q")
        Dim sql As New SqlCommand
        sql.Connection = clDb.getConnection
        sql.CommandText = ("select CityName, CityId from tblCityVariant where " & _
                           "CityName like @SearchText + '%'")
        sql.Parameters.AddWithValue("@SearchText", prefixText)
        Dim sb As StringBuilder = New StringBuilder
        Dim sqlReader As SqlDataReader = sql.ExecuteReader

        While sqlReader.Read
            sb.Append( & sqlReader.Item(0)).Append(Environment.NewLine)
        End While

    End Sub
    Public ReadOnly Property IsReusable() As Boo
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend