Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3617176
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:35:25+00:00 2026-05-18T22:35:25+00:00

I have an ASP.NET web service that returns a user’s friends list in JSON

  • 0

I have an ASP.NET web service that returns a user’s friends list in JSON form so that it may populate the AutoSuggest plugin data source. I’m using ASP.NET 4.0 and jQuery 1.4.4 minified. When I try to invoke the autoSuggest method, the following code doesn’t seem to work. It applies the startText value to my text box, but it doesn’t populate the datasource.

$(document).ready(function () {
        $("input[type=text]").autoSuggest("GetFriends.asmx/GetFriendsList", { minChars: 2, matchCase: false, startText: "Search Username" });
    });  

Here’s my text box control:

<asp:TextBox ID="tbSearch" runat="server"></asp:TextBox>

Here’s the relevant part to my web service:

[WebMethod]
public string GetFriendsList()
{
    DataTable dt = GetFriends();
    List<Friend> friends = new List<Friend>();
    string[] items = new string[dt.Rows.Count];

    for (int i=0; i< dt.Rows.Count; i++)
    {
        DataRow dr = dt.Rows[i];
        Friend friend = new Friend();
        friend.value= dr["UserId"].ToString();
        friend.name= dr["UserName"].ToString();
        friends.Add(friend);
    }
    return JsonConvert.SerializeObject(friends, Formatting.Indented);
}

Any suggestions on how I should populate the data source for the AutoSuggest plugin from my web service?
Here’s a link to the developer’s page: http://code.drewwilson.com/entry/autosuggest-jquery-plugin

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T22:35:26+00:00Added an answer on May 18, 2026 at 10:35 pm

    After doing a little more research, I found that ASP .NET WebServices do not return data without being enclosed in XML first. I decided to go with a generic handler and render the JSON using the handler. I used my existing code to encode the JSON and then rendered the JSON like this:

        string str = Newtonsoft.Json.JsonConvert.SerializeObject(data, Newtonsoft.Json.Formatting.Indented);
        context.Response.ContentType = "application/json";
        context.Response.Write(str);
    

    I put the above code in the ProcessRequest method of my handler and all works well now. There may be other methods to render JSON available, but this one works for the time being.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.NET WebService that returns an object of List public class Students
i have an ASP.NET web service that returning a custom entity object (Staff): [WebMethod]
I have an ASP.net web service that I'm using for a web application which
I have an ASP.NET web service that I can access via a windows program
I have an ASP.NET web service running that accepts both HTTP POST and SOAP
I have a asp.net website and I am accessing that web service from my
I have a windows forms client that consumes an ASP.net web service. It's my
Interesting one here. I have an ASP.NET 1.1 project that contains a web service
I have an asp.net MVC2 application that needs to call a web service from
In a C# ASP .NET application I have a web service that receives a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.