1) while editing a view with the row:
@Html.TextArea(name: "Message", rows: 10, columns: 40)
I'm getting this error at compile time:
ERR: "The best overload for 'TextArea' does not have a parameter of type 'rows'"
even if there's a signature with rows and columns as parameters.
2) So I try with the signature: @Html.TextArea(string name, object htmlAttributes)
invoking the function as follows
@Html.TextArea(name: "Message", new { rows=10, columns=40 }
but I'm getting another error:
ERR: "Named Argument Specifications must appear after all fixed arguments have been specified"
Anyone knows why and how to solve them?
Thank you in advance!
Create TextArea in ASP.NET MVC The HtmlHelper class includes two extension methods to render multi-line <textarea> HTML control in a razor view: TextArea() and TextAreaFor<TModel, TProperty>() . By default, it creates a textarea with rows=2 and cols=20.
The <textarea> tag defines a multi-line text input control. The <textarea> element is often used in a form, to collect user inputs like comments or reviews. A text area can hold an unlimited number of characters, and the text renders in a fixed-width font (usually Courier).
Why not just :
@Html.TextAreaFor(model => model.Body, new { cols = 35, @rows = 3 })
Just change the code to:
@Html.TextArea("Message", new { rows=10, columns=40 })
without the named parameter
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