使用Html.EditorFor产生具有行和列的一个特定数目的文本区域 [英] Using Html.EditorFor to generate a textarea with a specific number of rows and columns
问题描述
我知道你可以使用的数据类型的属性和EditorFor HTML辅助指定模型实体的特定属性应显示为多行输入字段。
I know you can use the DataType attribute with the EditorFor html helper to specify that a particular property of a model entity should be displayed as a multi-line input field.
如果我想指定的行和列文本区域必须有多少?
What If I want to specify the number of rows and columns the text area must have?
在模型中:
[DataType(DataType.MultilineText)]
public string HTMLText { get; set; }
在该视图:
@Html.EditorFor(x => x.HTMLText)
通缉的结果:
<textarea id="HTMLText" rows="10" cols="40">value</textarea>
有没有办法来产生这种code,而不使用@ Html.Textarea()帮助?
Is there a way to generate this kind of code without using the @Html.Textarea() helper?
推荐答案
不知道如何设置行列数,但你可以使用。多行<改变这些文字区域的CSS / code>类。这个类是使用EditorFor时,这样你就可以在该类得到你想要的尺寸指定的宽度和高度添加到textarea的。
Not sure how to set the rows and cols, but you can alter the CSS of those textareas using the .multi-line
class. This class is added to the textarea when using EditorFor so you can specify the width and height in that class to get your desired dimensions.
.multi-line { height:5em; width:5em; }
这篇关于使用Html.EditorFor产生具有行和列的一个特定数目的文本区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!