C# 如何更改多行编辑器字段的大小?
我正在使用C#进行一个MVC项目。现在,我正在尝试自定义一点我的视图,我想把文本框变大一些 我按照此问题中的建议,从单行文本字段移动到多行文本字段: 现在我正在尝试调整多行字段的大小,但我不确定在哪里或如何调整 以下是我的编辑视图中的片段C# 如何更改多行编辑器字段的大小?,c#,html,asp.net-mvc,asp.net-mvc-3,multiline,C#,Html,Asp.net Mvc,Asp.net Mvc 3,Multiline,我正在使用C#进行一个MVC项目。现在,我正在尝试自定义一点我的视图,我想把文本框变大一些 我按照此问题中的建议,从单行文本字段移动到多行文本字段: 现在我正在尝试调整多行字段的大小,但我不确定在哪里或如何调整 以下是我的编辑视图中的片段 <div class="editor-label"> @Html.LabelFor(model => model.Body) </div> <div class="editor-field"> @
<div class="editor-label">
@Html.LabelFor(model => model.Body)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Body)
@Html.ValidationMessageFor(model => model.Body)
</div>
我会用CSS来实现这一点:
<div class="editor-multiline-field">
@Html.EditorFor(model => model.Body)
@Html.ValidationMessageFor(model => model.Body)
</div>
您也可以使用@Html.TextArea ou TextAreaFor
@Html.TextAreaFor(model => model.Text, new { cols = 25, @rows = 5 })
试一试
@TextAreaFor(model=>model.descripao,5,50,null)
如果您正在使用mvc和引导,请在查看页面中 试试这个:
@Html.TextAreaFor(model => model.Property, new { @class = "form-control", @rows = 5 })
在MVC5中,您可以使用
@Html.TextAreaFor(model => model.body, 5, 50, new { @class = "form-control" } )
很好用 要坚持以前创建的视图样式,还可以执行以下操作:
<div class="col-md-10 editor-multiline-field">
我只想和大家分享一下MVC5
@Html.EditorFor(model => model.Body,
new {htmlAttributes = new {@style="width:yourdesiredwidth;"}
})
或者使用自定义类它对我不起作用。我使用了上面的例子,但没有改变html.editorfor字段的宽度。我必须从我的自定义.editor多行字段中删除“textarea”才能正确调整大小。editor多行字段对我不起作用,但这个答案对我有效!谢谢
<div class="col-md-10 editor-multiline-field">
@Html.EditorFor(model => model.Body,
new {htmlAttributes = new {@style="width:yourdesiredwidth;"}
})