Search code examples
asp.net-mvcasp.net-mvc-4razoractionlink

passing multiple parameters in @html.actionlink()


I'm using actionlink to pass parameter "code" to controller for an item and get details for that item on new view (actually, it's controller that calls 3 partial views)

I also need to pass parameter "description" but that's just an value that need to be shown as on new view and has no use in controller (i'm using "code" to filter database records).

@foreach (var item in Model.MyModel)
{
  <tr>
    <td>
      @Html.ActionLink(item.code, "Index", "ControlerName", new { pos = item.code.ToString(), desc = item.desc.ToString() }, null)
</td>

}

this actionlink give me url /ControlerName?pos=code&desc=desc

Is there a way to send "desc" parameter so it won't be seen in url but only shown as in new view?


Solution

  • No, Html.ActionLink only exists to generate a url and plop it inside an anchor tag. You should be repopulating the desc value from your Index action when it's hit.