2013-01-11 110 views
3

使用的HtmlHelper创建文本区域:ASP .NET MVC 4 在我的网页之一,我需要一个textarea的具有一定的宽度和高度使用HTML 辅助类。我的一些代码下面给出:与ASP.NET的MVC 4

<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

http://stackoverflow.com/questions/5119221/how-can-i-change-the-size-of-a-multi-line-editor -field –

+0

你需要编辑器的高度来设置?或者你需要使用textarea并设置其高度和宽度? –

+0

@AliRızaAdıyahşi,谢谢。可以定义列/行可以响应? –

回答

2

我有这个问题。我对于新手,所以我真的不知道,但使用我能调整高度以下...

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

我还是不知道如何调整宽度,我目前谷歌的使命...

5

我意识到这个问题是一岁多,但以防万一有人正在寻找的答案,那就是:

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>