Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET razor Html.TextArea

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!

like image 451
Zeta Avatar asked Mar 07 '13 16:03

Zeta


People also ask

How to add TextArea in ASP net?

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.

What is the input type for textarea in HTML?

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).


2 Answers

Why not just :

@Html.TextAreaFor(model => model.Body, new { cols = 35, @rows = 3 })
like image 93
Badr Bellaj Avatar answered Oct 02 '22 09:10

Badr Bellaj


Just change the code to:

@Html.TextArea("Message", new { rows=10, columns=40 })

without the named parameter

like image 32
thitemple Avatar answered Oct 02 '22 09:10

thitemple