Milan Mendpara
Milan Mendpara

Reputation: 3131

how do i pass multiple parameter to action method from view

i'm doing something like this in category.cshtml view page

<select onchange="location = this.value;">
            <option value="/product/categoryByPage/[email protected],limit=15" selected="selected">15</option>
            <option value="/product/categoryByPage/[email protected],limit=30"
selected="selected">30</option>
            <option value="/product/categoryByPage/[email protected],limit=50"
selected="selected">50</option>
    </select>

and from controller :

[ActionName("categoryByPage")]
 public ViewResult Category(Guid id, string limit)
 {
       Category cat = db.Categories.Find(id);
       return View(cat);
 }

but it isn't working and controller method unable to fetch that parameters ...

thanks in advance,

Milan

Upvotes: 2

Views: 752

Answers (1)

undefined
undefined

Reputation: 34248

you need to change your url as follows to work with default routing:

<option value="/product/categoryByPage/@Model.CategoryID?limit=50"
selected="selected">

Note that id is actually in the default route as the last argument, any extra parameters you need need to be provided in query string format

Upvotes: 1

Related Questions