I was using a textbox to do the following:
<input style="width:50px;" type="text" id="blah" value="@model.value1" @if(model.id!=1){ <text>disabled</text>}/>
This basically shows a textbox which is disabled under specific circumstances. I decided to replace this with a more "mvc-friendly" way.
@Html.TextBoxFor(m => model.value1, new { id = "blah" })
But not sure how to add in the disabled attribute (Dynamically) I can get it to do it statically easilly by adding a disabled=truevalue into the new{}.
I did try using this:
@if (<condition>) { var disable = true; }
@Html.TextBoxFor(m => model.value1, new { id = "blah", disabled = disable })
But this also didn't work. Am i taking the right approach here?