0

I'm currently having an issue while trying to pass Data to my controller in my MVC application.

Here is my code

  $('#idNumber')
            .autocomplete(
            {


                source: "/@Resources.Global.Lang/Client/AutoComplete?ID=" + $("#idNumber").val() + "&country=" + $("#country").val(),

                select: function (e, ui) {
                    var temp = $("#idNumber").val();
                    var temp2 = $("#country").val();
                    $.ajax({
                        type: 'POST',
                        url: "/@Resources.Global.Lang/Client/searchClientByID?ID=" + temp + "&country=" + temp2,
                        dataType: 'json',
                        success: function (data) {

                            $("#Client_CountryCode").val(data["CountryCode"]);
                            $("#country").val(data["Country"]);
                        }
                    });

                },
            });

This is my DropDownlist

        @Html.DropDownList("country", ((ClientController)ViewContext.Controller).GetCountries(), "United Kingdom", new { @class = "dropDownCountry",@id = "country" })

My method in ClientController always receive the default value I set for that dropdownlist, in this case United Kingdom and even if I change it to another value.
Can someone help me out? I have no idea why my Dropdownlist selected value doesn't work whenever I call the autocomplete function.

Edited by Diogo Martinho

2
Contributors
1
Reply
8
Views
4 Years
Discussion Span
Last Post by iamthwee
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.