无法向@ Html.TextAreaFor添加样式和占位符

问题描述 投票:1回答:1

我正在使用以下html标记:

@Html.TextAreaFor(Model => Model.TaxID, 
 new {styles = "width:30%; border-color: black; maxlength: 9" @placeholder = "xxxxxxxxx"})

我无法检索任何样式,最大长度超过9个字符,并且@placeholder抛出错误。有人可以帮我这个忙。

c# asp.net-mvc razor html-helper
1个回答
1
投票

正确的做法是这样的,请注意,它应该是“ style”而不是“ styles”,而且您还错过了style和占位符之间的,

new { placeholder = "xxx", maxlength=9,  style = "width:30%; border-color: black;" }
© www.soinside.com 2019 - 2024. All rights reserved.