views:

19

answers:

1

can we get the multiple values from a select tag through Ajax script in controller in asp.net MVC?

I Have tried for Single Value that I have done by .val Function..

But not for Multiple Values

Any suggestion Please Help

A: 

Yes you can create multi-select like this:

<select multiple="multiple" name="cars">
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="mercedes">Mercedes</option>
  <option value="audi">Audi</option>
</select>

And your controller's action should look like something this:

    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Index(string[] cars)
    {
        // ....
        return View();
    }

The ajax post codecan be the same as in your previous case.

Branislav Abadjimarinov