This is not a question of how to correctly attach a series of flags to a model property (general question) - my site works fine with reading the values ββof a flag from a request, or a POST request line, or GET +.
This is about how to use it Html.ActionLinkto create a link that correctly generates several checkbox values ββin the query string.
So, I have the following model:
public class ModelType
{
public string[] V { get; set; }
}
And I bind, say, 3 flags to this model in the view, since I have three possible values ββ(and, yes, combinations of the specified values).
Here is the final HTML
<INPUT id="chk1" value="1" type="checkbox" name="V">
<INPUT id="chk2" value="2" type="checkbox" name="V">
<INPUT id="chk3" value="3" type="checkbox" name="V">
, GET, , , ?V=1&V=2&V=3.
, .
, , , RouteValueDictionary ; , - :
1: ModelType :
<%= Html.ActionLink("Test link", null , new { V = Model.V }) %>
2: 'V' :
<%= Html.ActionLink("Test link", null ,
new { V = new string[] { "1", "2", "3" } }) %>
[ RouteValueDictionary, .]
: ?V=System.String%5B%5D.
, , ToString() ; , , MVC , ?V=1&V=2&V=3.
:
new { V="1", V="2", ... }
Nor RouteValueDictionary :
d["V"] = "1"; d["V"] = "2"; ...
RouteValueDictionary, IEnumerable<string> , , - : ?V=1%2C2%2C3.
, , MVC ββ ( ); , , , , .
, .
- ? ActionLink, , ?
, , .