2016-05-03 64 views
0

嗨,我有一個文本區域的域名爲說明在我看來。我希望增加該字段的大小。如何在html剃刀視圖mvc4中增加TextArea的大小?

我的代碼

<div class="col-sm-3"> 
    <div class="form-group"> 
    <span style="color: #f00">*</span> 
    @Html.LabelFor(model => model.Description, new { @class = "control-label" }) 
    @Html.TextAreaFor(model => model.Description, new { @class = "required", style = " rows=10, columns=40" }) 
    @Html.ValidationMessageFor(model => model.Description) 
     </div> 
    </div> 

我的文本區

TextArea

我希望把像它下面的圖像中提

Wanted Output

所以我給了textarea字段中的行和列。它增加了文本區域的大小。但是當我把頁面縮小到手機尺寸意味着所有字段都縮小了。但是這個textarea字段不會縮小到頁面大小。這是問題

我保持對我的字段進行驗證。我想以紅色顯示驗證。我使用模型驗證。所以請任何人解決這兩個問題。

提前謝謝..

+0

如果解決您的問題請分享或哪一個幫助解決您的問題,請標記爲已回答 –

回答

0

RowsCols不來下style標籤。它是textarea的一個獨立屬性。你可以寫下如下。

@Html.TextAreaFor(model => model.Description, new { @class = "required", @cols = 40, @rows = 10}) 
2

試試這個:

@Html.TextAreaFor(model => model.Description, 10,40, htmlAttributes: new {style="width: 100%; max-width: 100%;" }) 
0
Remove textArea element from site.css file. In site.css textarea max-width set as 280px; 
Do like 

input 
,select 
/*,textarea*/ 
{ 
    max-width: 280px; 
} 
-1
@Html.TextAreaFor(m => m.Description, 10, 40, new { @class = "form-control required", style="max-width:75% !important;" }) 
2

雖然這已經回答了,有人在那裏可能仍然需要這個。

@ Html.TextAreaFor(型號=> model.comments,新的{@cols = 「100」,@rows = 「8」,@風格= 「寬度:100%;」})