I have a form using a control with multiple = "multitple" attribute. This allows the user to select more than one item in the control.
When the form is submitted with the get method, the url of the requested page contains one multiple parameter with the same name. One for each selected item. For example, I could get something like this:
/logs?levels=DEBUG&levels=INFO&levels=FATAL
In my controller, the action correctly takes values ββin the parameters of type List, for example:
public ActionResult Index(List<String> levels) { ... }
Now for some reason I need to create a link to this action, which will contain more than one value for the levels parameter. How can I use Html.ActionLink to create such a link? I tried it like this:
@Html.ActionLink((p + 1).ToString(), "Index", new { levels = ViewBag.selectedLevels_AS_A_GENERIC_LIST_OF_STRINGS, itemsPerPage = ViewBag.itemsPerPage });
This does not work because the list is not decrypted in any way; instead, .ToString () is called on it, and the result is inserted into the link. Of course, for me there is no way to create an object with multiples parameters with the inscription "levels".
How to create ActionLink as created by the form that I use?
thanks
source share