ASP.NET MVC3 - textarea with @Html.EditorFor

后端 未结 4 633
猫巷女王i
猫巷女王i 2020-12-12 10:31

I have ASP.NET MVC3 app and I have also form for add news. When VS2010 created default view I have only text inputs for string data, but I want to have textarea for news tex

4条回答
  •  没有蜡笔的小新
    2020-12-12 10:48

    Someone asked about adding attributes (specifically, 'rows' and 'cols'). If you're using Razor, you could just do this:

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

    That works for me. The '@' is used to escape keywords so they are treated as variables/properties.

提交回复
热议问题