I have an ASP.NET Core 2.0 web application that generates a multi-select list box using bootstrap-multiselect (basically a prettied up list box control)
The code generated is shown:
<select class="multiselect-ui form-control" id="Issues" multiple="multiple" name="Issues">
<option selected="selected" value="1">Dilapidated Structures</option>
<option selected="selected" value="3">Junk on Premises</option>
<option selected="selected" value="4">Junk Vehicles</option>
<option selected="selected" value="5">Minor Maintenance</option>
<option selected="selected" value="6">Miscellaneous</option>
<option selected="selected" value="7">Overgrowth</option>
<option selected="selected" value="8">Right of Way</option>
<option selected="selected" value="9">Sidewalks</option>
<option selected="selected" value="10">Trash</option>
<option selected="selected" value="2">Weeds/High Grass</option>
</select>
When this is submitted in a form, I see the Issues
being added to the URL like so:
/Cases?Issues=1&Issues=3&Issues=4&Issues=5 ...
This is great and I am able to retrieve the values in my controller using a List<string>
object. My question is, how would I add a hyperlink to the page that uses the values already sent via GET? Basically I would like to use Tag Helpers, but there is no way to add an array of values that I've found. There are dictionary key/pairs, but of course you are not able to add multiple values with the same key. I would like to be able to reference a List<string>
in the tag helper itself (the following does not work, but should give an idea of what I'm after if I am sending the List<string>
back using ViewBag):
<a asp-route-Issues=@ViewBag.IssuesList>Next</a>
I found out through this link that this feature isn't implemented. I used @Url.Action
to build my link as shown (where ViewBag.IssuesList
contains the List<string>
-- I also left out some paramters for brevity:
<a href="@Url.Action("Index", "Cases", new { Issues = ViewBag.IssuesList })">Previous</a>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.