Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default value for textarea

I'm trying to create a textarea element with a default value with the help of the ASP.NET MVC TextAreaFor method.

<%= Html.TextAreaFor(a => a.Description, new { Class = "gray", rows = "1", cols = "1", @onclick = "clearGray($(this));", Value = "Test sentence" })%>

The box is there, but I don't see the value I set. It appears when inspecting, but not in the textarea. I know you're supposed to set it like <textarea>Test sentence</textarea>, but I don't know how to do that with the helper method.

I tried using a Content attribute, but that didn't work obviously. Any solutions?

like image 725
Edgar Avatar asked Mar 08 '26 14:03

Edgar


1 Answers

Look at ASP.NET MVC - How can I set the Default Value in a Strongly Typed TextArea?

like image 153
Gabriele Petrioli Avatar answered Mar 11 '26 02:03

Gabriele Petrioli



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!