0

I have two dropdowns coming from a resource file. In the first dropdown, I have four options and according to that selection, I need to populate the second dropdown which would be coming from unique resource file according to selection. In the resource file, I have a master resource file with 4 fields(a,b,c,d) then I have 4 different resource files to go along with each selection. Can anyone tell me how can I populate that in the MVC 4?

@Html.DropDownListFor(m => m.country, new SelectList(frontend.Resources.Country.ResourceManager.GetResourceSet(System.Globalization.CultureInfo.CurrentCulture, true, true), "Key", "Value").OrderBy(p => p.Value))

@Html.DropDownListFor(m => m.city, new SelectList(frontend.Resources.City1.ResourceManager.GetResourceSet(System.Globalization.CultureInfo.CurrentCulture, true, true), "Key", "Value").OrderBy(p => p.Value))
@Html.DropDownListFor(m => m.city, new SelectList(frontend.Resources.City2.ResourceManager.GetResourceSet(System.Globalization.CultureInfo.CurrentCulture, true, true), "Key", "Value").OrderBy(p => p.Value))
@Html.DropDownListFor(m => m.city, new SelectList(frontend.Resources.City3.ResourceManager.GetResourceSet(System.Globalization.CultureInfo.CurrentCulture, true, true), "Key", "Value").OrderBy(p => p.Value))
@Html.DropDownListFor(m => m.city, new SelectList(frontend.Resources.City.ResourceManager.GetResourceSet(System.Globalization.CultureInfo.CurrentCulture, true, true), "Key", "Value").OrderBy(p => p.Value))
user2859625
  • 29
  • 2
  • 5

1 Answers1

0

use an ajax call

$('#country').change(function() {
    $.ajax({
        url: "@(Url.Action("Action", "Controller"))",
        type: "POST",
        cache: false,
        async: true,
        data: { data: $('#country').val() },
        success: function (result) {
        //use the code from the link
        }
   });
});

you can have a call for each dropdown and can call any method on any controller to get data back. Hopefully this helps.

Matt Bodily
  • 6,403
  • 4
  • 29
  • 48