Search code examples
asp.net-mvc

Adding Read Only to @Html.TextBoxFor


I've tried to adding a readonly attribute but this does not work.

@Html.TextBoxFor(m => m.Test.ClientNumber, new { readonly = "readonly", @name = "client" @id="validate" @class = "form-control" })

I was able to add the required attribute but the readonly won't work.


Solution

  • @Html.TextBoxFor(m => m.Test.ClientNumber, new { @readonly = "readonly", @name = "client", @id = "validate", @class = "form-control" })
    

    I think you have missed @ for readonly attribute.