I have a C#.Net MVC3 web app and we use HTML.TextAreaFor() text areas for editting and display. In one instance it should be edittable and in another it shuold be display only. How would I accomplish this? Is there another element I should use or can I make the TextAreaFor disabled? Also, the TextAreaFor needs to word wrap in the display only mode as well...it's in a grid cell
Just use the htmlAttributes
parameter:
@Html.TextAreaFor(model => model.Something, new { @readonly = true })
To tidy up the if
/ else
in your View, use an extension method which does the if check and renders out the different textbox.
Not sure what you mean about word wrapping - from my understanding <textarea>
elements always wrap, unless you use wrap="off"
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