ASP.NET razor Html.TextArea
Asked Answered
L

4

13

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!

Lachrymator answered 7/3, 2013 at 16:54 Comment(0)
L
28

Just change the code to:

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

without the named parameter

Letaletch answered 7/3, 2013 at 17:0 Comment(2)
Perfect that was the problem of the second issue. While for the first one it's necessary to specify all the tags of the signature: Html.TextArea(name:"Message", rows: 10, columns: 40, value:"", htmlAttributes: new {})Lachrymator
Seems like "columns" isn't working, but "cols" is. So if you have the same problem like me, try this.Lorica
A
11

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

Affine answered 7/3, 2013 at 17:0 Comment(1)
It's ok without the tag. Both cols and columns are ok to set the attribute. Thanks.Lachrymator
N
3

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

@Html.TextArea("Message", new { rows=10, columns=40 })
Nostomania answered 7/3, 2013 at 17:0 Comment(0)
B
2

Why not just :

@Html.TextAreaFor(model => model.Body, new { cols = 35, @rows = 3 })
Bumptious answered 11/3, 2019 at 16:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.