troubleshooting Question

JSON -- populate two textboxes after user SELECTION ?

Avatar of finance_teacher
finance_teacher asked on
C#.NET ProgrammingASP.NET
2 Comments1 Solution463 ViewsLast Modified:
Currently everything gets saved into
which I do NOT want.

How can I change below code so step #4 populates
@Html.TextBox("productName") with selected c.PartNumber
and @Html.TextBox("productDescription") with its
associated c.PartDescription ?

 1. user enters data into @Html.TextBox("productName")
 2. search automatically populates @Html.TextBox("productName")
    with possible c.PartNumber --->  c.PartDescription) results
 3. user selects a results
 4. @Html.TextBox("productName") gets updated with
    selected c.PartNumber --->  c.PartDescription)
        public JsonResult getData(string term)

            var mySearchResults = db.Lookup_PartNumbers
                                    .Where(c => c.PartNumber.Contains(term) || c.PartDescription.Contains(term))
                                    .Select(c => c.PartNumber + "  --->  " + c.PartDescription)

            return Json(mySearchResults, JsonRequestBehavior.AllowGet);
    <script type="text/javascript">
        $(function () {
                source: function (request, response) {
                    $.getJSON("/AutoComplete/getData?term=" + request.term, function (data) {
                minLength: 2,
                delay: 100
               Product: @Html.TextBox("productName")
                Description: @Html.TextBox("productDescription")

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros