I have the following tag with a Html.TextBoxFor expression and I want the contents to be read only, is this possible?
<%= Html.TextBoxFor(m => Model.Events.Subscribed[i].Action)%>
The TextBoxes can be made ReadOnly by setting the HTML ReadOnly attribute using the HtmlAttributes parameter in Html. TextBox and Html. TextBoxFor helper functions.
Solution 1 In razor, everything is easy just add @readonly attribute to the code will do the needful.
Both of them provide the same HTML output, “HTML. TextBoxFor” is strongly typed while “HTML. TextBox” isn't. Below is a simple HTML code which just creates a simple textbox with “CustomerCode” as name.
<%= Html.TextBoxFor(m => Model.Events.Subscribed[i].Action, new { @readonly = true })%>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With