在ASP.NET MVC 4中,如何用HtmlHelper构建textarea标签?
- 内容介绍
- 文章标签
- 相关推荐
本文共计331个文字,预计阅读时间需要2分钟。
使用ASP.NET MVC 4在页面中添加具有特定宽度和高度的textarea,可以使用HTML helper类。以下是一个简化的示例代码:
@Html.LabelFor(model=> model.MailSubject) @Html.TextAreaFor(model=> model.MailSubject, new { rows=5, cols=40 })
使用:ASP .NET MVC 4在我的一个页面中,我需要一个具有一定宽度和高度的textarea,使用html helper类.我的一些代码如下:
<div class="editor-label"> @Html.LabelFor(model => model.MailSubject) </div> <div class="editor-field"> @Html.EditorFor(model => model.MailSubject) @Html.ValidationMessageFor(model => model.MailSubject) </div> <div class="editor-label"> @Html.LabelFor(model => model.MailBody) </div> <div class="editor-field"> @Html.EditorFor(model => model.MailBody) @Html.ValidationMessageFor(model => model.MailBody) </div> <div class="editor-label"> @Html.LabelFor(model => model.Content) </div> <div class="editor-field1"> @Html.EditorFor(model => model.Content) @Html.ValidationMessageFor(model => model.Content) </div>
我想知道如何定义editorfor(model.content)的大小(宽度/隐藏)?
Html.TextAreaFor(model => model.Field, new { rows = "", cols = "", style = "width: 90%; height: 50px;" })
您可以内联应用样式或使用类声明.这将在页面上呈现textarea,如下所示:
<textarea class="swiper-no-swiping" name="model.Field" cols="" rows="" style="width: 90%; height: 50px;"></textarea>
本文共计331个文字,预计阅读时间需要2分钟。
使用ASP.NET MVC 4在页面中添加具有特定宽度和高度的textarea,可以使用HTML helper类。以下是一个简化的示例代码:
@Html.LabelFor(model=> model.MailSubject) @Html.TextAreaFor(model=> model.MailSubject, new { rows=5, cols=40 })
使用:ASP .NET MVC 4在我的一个页面中,我需要一个具有一定宽度和高度的textarea,使用html helper类.我的一些代码如下:
<div class="editor-label"> @Html.LabelFor(model => model.MailSubject) </div> <div class="editor-field"> @Html.EditorFor(model => model.MailSubject) @Html.ValidationMessageFor(model => model.MailSubject) </div> <div class="editor-label"> @Html.LabelFor(model => model.MailBody) </div> <div class="editor-field"> @Html.EditorFor(model => model.MailBody) @Html.ValidationMessageFor(model => model.MailBody) </div> <div class="editor-label"> @Html.LabelFor(model => model.Content) </div> <div class="editor-field1"> @Html.EditorFor(model => model.Content) @Html.ValidationMessageFor(model => model.Content) </div>
我想知道如何定义editorfor(model.content)的大小(宽度/隐藏)?
Html.TextAreaFor(model => model.Field, new { rows = "", cols = "", style = "width: 90%; height: 50px;" })
您可以内联应用样式或使用类声明.这将在页面上呈现textarea,如下所示:
<textarea class="swiper-no-swiping" name="model.Field" cols="" rows="" style="width: 90%; height: 50px;"></textarea>

