我的视图文本框,下拉列表等中的元素很少.所有元素都有一些像这样创建的独特属性
<%: Html.DropDownListFor(model => model.MyModel.MyType, EnumHelper.GetSelectList< MyType >(),new { @class = "someclass", @someattrt = "someattrt"})%>
Run Code Online (Sandbox Code Playgroud)
我想通过设置另一个属性禁用来创建我的页面的只读版本.
有人知道我怎么能使用可以全局设置的变量来做到这一点?
就像是:
If(pageReadOnly){
isReadOnlyAttr = @disabled = "disabled";
}else
{
isReadOnlyAttr =””
}
<%: Html.DropDownListFor(model => model.MyModel.MyType, EnumHelper.GetSelectList< MyType >(),new { @class = "someclass", @someattrt = "someattrt",isReadOnlyAttr})%>
Run Code Online (Sandbox Code Playgroud)
我不想使用JavaScript来做到这一点