Paolo
Paolo

Reputation: 627

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!

Upvotes: 13

Views: 56488

Answers (4)

Badr Bellaj
Badr Bellaj

Reputation: 12841

Why not just :

@Html.TextAreaFor(model => model.Body, new { cols = 35, @rows = 3 })

Upvotes: 2

jmoerdyk
jmoerdyk

Reputation: 5521

ave you tried removing the name tag off of the name parameter?

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

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

Upvotes: 11

Tom Riley
Tom Riley

Reputation: 1722

I believe you need to add it as an attribute like so...

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

Upvotes: 3

thitemple
thitemple

Reputation: 6059

Just change the code to:

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

without the named parameter

Upvotes: 28

Related Questions