How to create a readonly textbox in ASP.NET MVC3 Razor

The Solution to How to create a readonly textbox in ASP.NET MVC3 Razor is


@Html.TextBoxFor(m => m.userCode, new { @readonly="readonly" })

You are welcome to make an HTML Helper for this, but this is simply just an HTML attribute like any other. Would you make an HTML Helper for a text box that has other attributes?

~ Answered on 2012-01-06 17:15:18


Most Viewed Questions: