如何指定一个多行编辑器,对于ASP.MVC的行和列? [英] How do I specify the columns and rows of a multiline Editor-For in ASP.MVC?

查看:135
本文介绍了如何指定一个多行编辑器,对于ASP.MVC的行和列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在ASP.MVC 3,我如何指定的行和列的多行 EditorFor (textarea的)?我使用 [UIHint(MultilineText)] ,但无法找到如何添加属性的文本区域的任何文件。

In ASP.MVC 3, how do I specify the columns and rows for a multiline EditorFor (textarea)? I am using [UIHint("MultilineText")], but can't find any documentation on how to add attributes for the text area.

所需的HTML:

 <textarea cols="40" rows="10"></textarea>

我的MVC 3型号的相关部分:

Relevant Part of my MVC 3 Model:

[UIHint("MultilineText")]
public string Description { get; set; }

我的剃须刀CSHTML的相关部分:

Relevant Part of my Razor cshtml:

<div class="editor-field">
    @Html.EditorFor(model => model.Description)
</div>

什么我得到在查看源代码:

What I'm getting in View Source:

 <div class="editor-field">
     <textarea class="text-box multi-line" id="Description" name="Description"></textarea>
 </div>

如何设置的行和列?

How do I set rows and columns?

推荐答案

使用TextAreaFor

Use TextAreaFor

@Html.TextAreaFor(model => model.Description, new { @class = "whatever-class", @cols = 80, @rows = 10 })

多线式的使用类。

您也可以写<一个href=\"http://geekswithblogs.net/michelotti/archive/2010/02/05/mvc-2-editor-template-with-datetime.aspx\">EditorTemplate这一点。

这篇关于如何指定一个多行编辑器,对于ASP.MVC的行和列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆