我如何将 checkboxfor htmlhelper 与 class 的 bool 属性 一起使用,这是我的视图模型的 属性
How do I use checkboxfor htmlhelper with a bool property of class that is a property of my viewmodel
我认为通过下面的示例可以更好地理解我的问题。
public Class1
{
public bool SomeProperty1 {get;set;}
public string SomeProperty2 {get;set;}
}
public Class2
{
//bool property in which i want to use the checkboxfor
public List<Class1> SomeProperty3 {get;set;}
public string SomeProperty4 {get;set;}
}
@model Class2
@Html.Textboxfor(SomeProperty4)...
.
.
.
@foreach(var x in SomeProperty3)
{
<td>Html.Checkboxfor(model=>x.SomeProperty1...) </td>
//How?
}
我也不知道如何将禁用的 属性 添加到 html 元素。
您可以使用 html 属性,如下所示。
Html.Checkboxfor(model=>x.SomeProperty1,new {@disabled="diasbled"})
我认为通过下面的示例可以更好地理解我的问题。
public Class1
{
public bool SomeProperty1 {get;set;}
public string SomeProperty2 {get;set;}
}
public Class2
{
//bool property in which i want to use the checkboxfor
public List<Class1> SomeProperty3 {get;set;}
public string SomeProperty4 {get;set;}
}
@model Class2
@Html.Textboxfor(SomeProperty4)...
.
.
.
@foreach(var x in SomeProperty3)
{
<td>Html.Checkboxfor(model=>x.SomeProperty1...) </td>
//How?
}
我也不知道如何将禁用的 属性 添加到 html 元素。
您可以使用 html 属性,如下所示。
Html.Checkboxfor(model=>x.SomeProperty1,new {@disabled="diasbled"})