ASP.NET razor Html.TextArea

1) when editing a view using the line:

@Html.TextArea(name: "Message", rows: 10, columns: 40) 

I get this error at compile time:

 ERR: "The best overload for 'TextArea' does not have a parameter of type 'rows'" 

even if there is a signature with rows and columns as parameters.

2) So I try with the signature: @ Html.TextArea (string name, htmlAttributes object)

calls the function as follows

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

but I get another error:

 ERR: "Named Argument Specifications must appear after all fixed arguments have been specified" 

Does anyone know why and how to solve them?

Thank you in advance!

+8
html-helper textarea
source share
3 answers

Just change the code to:

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

without named parameter

+15
source share

ave you tried to remove the name tag from the name parameter?

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

Also, the HTML attribute for columns on textarea is cols not columns

+9
source share

I believe you need to add it as an attribute similar to this ...

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

All Articles