Reputation: 749
In my page i have
@using (Html.BeginForm("list", "menu", FormMethod.Get))
{
<div>
Show categories:
@Html.DropDownList("groupName", (SelectList)ViewBag.groups)
<input id="Submit1" type="submit" value="Show" />
</div>
}
Regarding the option the user choose i generate a list and the Querystring in my address going to be like :
localhost/menu/list?groupName=controlpanel
My problem is when i use HtmlActionLink for example :
@Html.ActionLink("Title", "List", new { foo = item.foo})
What i got in result is result is :
localhost/menu/List?foo=123
instead of :
localhost/menu/List?foo=123&groupName=controlpanel
Am i missing something ??
Upvotes: 4
Views: 6475
Reputation: 4262
To use ActionLink, you need to include all of the parameters you want to appear in the query string. The easiest thing I think would be is to add a GroupName property on your model (or in the ViewBag like your other sample). Then you can do this:
@Html.ActionLink("Title", "List", new { foo = item.foo, groupName = Model.GroupName })
Upvotes: 1
Reputation: 4070
It is not a built in solution, even though it seems to address exactly what you are looking for:
ASP.NET MVC Build Url Based on Current Url
Upvotes: 5