ASP .NET MVC - CheckBox
MVC CheckBox 的使用
普通 checkbox
<input type="checkbox" value="check1" name="obj" /> <input type="checkbox" value="check2" name="obj" /> <input type="checkbox" value="check3" name="obj" />
无value | 有value | |
object | string[] : ["on", "on"] | string[] : ["value1", "value2"] |
string | string : "on" | string : value1 |
string[] | string[] : ["on", "on"] | string[] : ["value1", "value2"] |
Dictionary<string, bool> | null | null |
bool[] | null | null |
<input type="checkbox" value="check1" name="obj[0]" /> <input type="checkbox" value="check2" name="obj[1]" /> <input type="checkbox" value="check3" name="obj[2]" />
无value | 有value | |
object | null | null |
string | null | null |
string[] | null | null |
Dictionary<string, bool> | dictionary[] : [{1, "False"}, {2, "False"}] | dictionary[] : [{1, "False"}, {2, "False"}] |
bool[] | null | null |
<input type="text" name="obj[0].s" value="value1"/> <input type="text" name="obj[1].s" value="value2" /> <input type="text" name="obj[2].s" value="value3" /> <input type="checkbox" name="obj[0].v" /> <input type="checkbox" name="obj[1].v" /> <input type="checkbox" name="obj[2].v" />
class | class : [{"value1", False}, {"Value2", False}, {"Value3", False}] |
MVC checkBox
@Html.CheckBox("obj", new { value = "value1" })
@Html.CheckBox("obj", new { value = "value2" })
@Html.CheckBox("obj", new { value = "value3" })
无value | 有value | |
object | string[] : ["false", "true", "false", "true", "false"] | string[] : ["false", "value1", "false","value2", "false"] |
string | string : "false" | string : value1 |
string[] | string[] : ["false", "true", "false", "true", "false"] | string[] : ["false", "value1", "false","value2", "false"] |
Dictionary<string, bool> | null | null |
bool[] | bool[] : [false, true, false, true, false] | null |
@Html.CheckBox("obj[0]")
@Html.CheckBox("obj[1]")
@Html.CheckBox("obj[2]")
无value | 有value | |
object | object | object |
string | null | null |
string[] | string[] : ["false", "true", "true"] | string[] : ["false", "value1","value2"] |
Dictionary<string, bool> | dictionary[] : [{0, False}{1, True}, {2, True}] | dictionary[] : [{0, False}{1, Flase}, {2, False}] |
bool[] | bool[] : [false, true, true] | bool[] : [false, false, false] |
@Html.CheckBox("obj[value1]")
@Html.CheckBox("obj[value2]")
@Html.CheckBox("obj[value3]")
无value | 有value | |
object | ||
string | ||
string[] | ||
Dictionary<string, bool> | dictionary[] : [{"value1", False}{"value2", True}, {"value3", True}] | |
bool[] |
@Html.TextBox("obj[0].s", "value1")
@Html.TextBox("obj[1].s", "value2")
@Html.TextBox("obj[2].s", "value3")
@Html.CheckBox("obj[0].v")
@Html.CheckBox("obj[1].v")
@Html.CheckBox("obj[2].v")
class | class : [{"value1", False}, {"Value2", True}, {"Value3", True}] |
KendoUI checkBox
@Html.Kendo().CheckBox().Name("obj1").HtmlAttributes(new { value = "value1" })
@Html.Kendo().CheckBox().Name("obj2").HtmlAttributes(new { value = "value2" })
@Html.Kendo().CheckBox().Name("obj3").HtmlAttributes(new { value = "value3" })
无value | 有value | |
object | string[]: ["true", "true"] | string[]: ["value1", "value2"] |
string | null | null |
string[] | null | null |
Dictionary<string, bool> | null | null |
bool[] | bool[] : [true, true] | null |
@Html.Kendo().CheckBox().Name("setting").HtmlAttributes(new { id = "a1", value = "value1" }))
@Html.Kendo().CheckBox().Name("setting").HtmlAttributes(new { id = "a2", value = "value2" }))
无value | 有value | |
string[] | string[]: [true, "value1", false, "value2"] | |
@Html.Kendo().CheckBox().Name("setting1").HtmlAttributes(new { id = j.Code, value = j.Code }))
@Html.Kendo().CheckBox().Name("setting2").HtmlAttributes(new { id = j.Code, value = j.Code }))