ASP.NET razor Html.TextArea

Zet*_*eta 11 asp.net textarea html-helper

1)在使用行编辑视图时:

    @Html.TextArea(name: "Message", rows: 10, columns: 40)
Run Code Online (Sandbox Code Playgroud)

我在编译时收到此错误:

ERR: "The best overload for 'TextArea' does not have a parameter of type 'rows'"
Run Code Online (Sandbox Code Playgroud)

即使有一个以行和列为参数的签名.

2)所以我尝试使用签名:@ Html.TextArea(字符串名称,对象htmlAttributes)

调用函数如下

    @Html.TextArea(name: "Message", new { rows=10, columns=40 }
Run Code Online (Sandbox Code Playgroud)

但我得到另一个错误:

ERR: "Named Argument Specifications must appear after all fixed arguments have been specified"
Run Code Online (Sandbox Code Playgroud)

谁知道为什么以及如何解决它们?

先感谢您!

thi*_*ple 23

只需将代码更改为:

@Html.TextArea("Message", new { rows=10, columns=40 })
Run Code Online (Sandbox Code Playgroud)

没有命名参数


jmo*_*dyk 11

你试过从名称参数中删除名称标签吗?

@Html.TextArea("Message", new { rows = 10, cols = 40})
Run Code Online (Sandbox Code Playgroud)

此外,a textarea上的列的HTML属性cols不是columns