2013-03-07 286 views
8

1) 同時編輯與該行一個觀點:ASP.NET剃刀Html.TextArea

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

我得到在編譯時這個錯誤:

即使有一個簽名
ERR: "The best overload for 'TextArea' does not have a parameter of type 'rows'" 

以行和列作爲參數。

2) 所以我嘗試用簽名: @ Html.TextArea(字符串名稱,對象htmlAttributes)

調用該函數如下

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

但我發現了另一個錯誤:

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

任何人都知道爲什麼以及如何解決它們?

預先感謝您!

回答

15

只要改變代碼:

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

沒有命名的參數

+0

完美的,這是第二個問題的問題。雖然第一個需要指定簽名的所有標籤:Html.TextArea(name:「Message」,rows:10,columns:40,value:「」,htmlAttributes:new {}) – Zeta 2013-03-08 08:33:32

+1

看起來像「列「不工作,但」cols「是。所以如果你有像我這樣的問題,試試這個。 – Tom 2014-06-24 07:18:02

2

我相信你需要將其添加爲像這樣的屬性...

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

完美的第二個問題,它很好。 – Zeta 2013-03-08 08:34:49

9

AVE你試過從名稱參數中刪除名稱標籤?

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

而且,列中的HTML屬性上textareacolscolumns

+0

沒有標籤沒關係。 cols和columns都可以設置屬性。謝謝。 – Zeta 2013-03-08 08:30:11