I have on one of my views the following razor code:
@if (item.PMApproved != true) {
A markup-centric solution aided by a new extension method:
public static class HtmlExtensions
{
public static HtmlString DisabledIf(this HtmlHelper html, bool condition)
{
return new HtmlString(condition ? "disabled=\"disabled\"" : "");
}
}
In your views, reuse out the wazoo:
Nicely reusable, and the rendered markup is very clean with regards to whitespace: