以下代码不工作.请纠正
@{ string displayMode = (Model.CompanyNameEnabled) ? "" : "disabled = disabled"; @Html.TextBox("CompanyName","",new { displayMode }) }
@{ object displayMode = (Model.CompanyNameEnabled) ? null : new {disabled = "disabled" }; @Html.TextBox("CompanyName",displayMode) }
您应该将htmlAttribute作为匿名对象传递,其属性名称为html属性名称,属性值=属性值.你的错误是你传递字符串而不是name = value对