Html.TextAreaFor in asp.net mvc

岁酱吖の 提交于 2019-12-01 02:36:51
Muhammad Adeel Zahid

Rendering TextArea using ASP.NET MVC's Html helper and making it resizable are two different concerns. When using Html helper you can add a class to textarea like

<%:Html.TextAreaFor(x => x.SomeProperty, new { @class = "resizer" }) %>

Then you can hook this class with jQuery to make it resizable when it's rendered on the web page. Please refer to Implementing a resizable textarea? for information about making your textarea resizable.

Use the code below when using Razor

   @Html.TextAreaFor(model => model.Comments, 10, 40, null);

Even better, if you want auto-calculate number of the rows in the textarea you can use this

@Html.TextAreaFor(m => m.Comments, Model.Comments.Count + 1, 40, null)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!