在ASP.NET MVC 4中使用HTML Helper创建文本区域

3

使用:ASP .NET MVC 4

在我的某个页面中,我需要一个带有特定宽度和高度的文本区域,使用HTML助手类。以下是我的一些代码:

    <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)的大小(宽度/高度)?


2
https://dev59.com/5W435IYBdhLWcg3w9E9Y - AliRıza Adıyahşi
你需要设置编辑器的高度吗?还是需要使用文本区并设置其高度和宽度? - Karthik Chintala
@AliRızaAdıyahşi,谢谢。定义列/行是否可以响应式? - Abdur Rahim
https://dev59.com/GGTVa4cB1Zd3GeqP_xp1 - AliRıza Adıyahşi
3个回答

5

我知道这个问题已经过去一年了,但以防有人正在寻找答案,这里是答案:

Html.TextAreaFor(model => model.Field, new { rows = "", cols = "", style = "width: 90%; height: 50px;" })

您可以选择将样式应用于行内或使用类声明。这将在页面上呈现文本区域,如下所示:
<textarea class="swiper-no-swiping" name="model.Field" cols="" rows="" style="width: 90%; height: 50px;"></textarea>

2

我遇到了这个问题。作为一个新手,我不是很确定,但是使用以下方法,我成功地调整了高度...

@Html.TextAreaFor(model => model.FullItinerary, 20, 10, null)

我仍然不知道如何调整宽度,我的目标是在Google上找到答案...


0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接