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 8855395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:07:32+00:00 2026-06-14T14:07:32+00:00

New to ASP.NET MVC and programming, and I have searched high and low for

  • 0

New to ASP.NET MVC and programming, and I have searched high and low for materials on this subject but haven’t found a concrete answer for my particular problem.

The project I am working on requires the use of WCF services. Initially I started with a jQuery autocomplete function that worked, however moving the code to a WCF service has broken some communication. The autocomplete functionality no longer works

WCF Service

public IList<Location> QuickSearchLocation(string term)
    {
        using (var db = new InspectionEntities())
        {
            //return all locations except the reserved "Other"
            return db.Locations
                .Where(r => r.LocationName.Contains(term) && r.LocationId !=    Constants.OtherId)
                .ToList();
        }
    } 

The above code is meant to takes user input based on relation to child table. If user input does not match data in child table, the users entry is saved to an “other” column in the main db.

Controller

public ActionResult QuickSearchLocation(string term)
    {
        return Json(_service.QuickSearchLocation(term), JsonRequestBehavior.AllowGet);
    }

View

div class="editor-field">
        @Html.TextBoxFor(m=>m.LocationId,new {data_autocomplete =     Url.Action("QuickSearchLocation", "Inspection")})

script

$(document).ready(function () {

$(":input[data-autocomplete]").each(function () {

    $(this).autocomplete({ source: $(this).attr("data-autocomplete")});
});

Any insight on my problem would be helpful.

  • 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-06-14T14:07:33+00:00Added an answer on June 14, 2026 at 2:07 pm

    Autocomplete expects either only labels or labels with values. On the other hand, you’re serving it the whole Location object.

    You should therefore, create a helper class:

    public class AutocompleteLocation{
        public AutocompleteLocation(Location location){
            label = location.LocationName;
            value = location.LocationId;
        }
        public string label {get;set;}
        public string value {get;set;}
    }
    

    After this, you should change your QuickSearchLocation controller method like this:

    public ActionResult QuickSearchLocation(string term)
    {
        return Json(_service.QuickSearchLocation(term).Select(l => new AutocompleteLocation(l)).ToList(), JsonRequestBehavior.AllowGet);
    }
    

    You should also consider not returning all the results but, rather, only first few (10 for example).

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

Sidebar

Related Questions

I'm not new to programming but am new to Visual Studio, MVC, C#, ASP.NET,
I have a new asp.net mvc project and i am trying to figure out
I created a new ASP.NET MVC application. The home page looks like this: I
I have created the following project structure for my new asp.net mvc project any
I have a new ASP.NET MVC 3 project, and MVC and Razor are all
i have to create a new asp.net mvc page that integrates content provided by
I have just set up a new ASP.NET MVC website and I would like
I get this error when running any new ASP.NET MVC 4 project: Compiler Error
Am new to programming and ASP.net MVC 3 so don't be surprised by my
I'm new to ASP.NET and have just starting to learn ASP.NET MVC 3. I've

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.