24

asp.net mvc で複数行のテキスト ボックスを作成するにはどうすればよいですか?

おそらくasp.net mvcに固有のものではありませんが、私が使用しているものです。

これが私が持っているものです。

<%: Html.TextBox("CommentToAdd", null, new
{
@class = "input-medium",    
TextMode = "MultiLine",
Columns = "55",
Rows = "10",
type = "text",
required = "required"
})%>
4

4 に答える 4

30

テキスト ボックスではなく、テキスト エリアを使用します。TextAreaForを使用してモデルにバインドします。それ以外の場合はTextAreaを使用します

<%= Html.TextAreaFor(e => e.CommentsToAdd, 10, 55, null) %>
<%= Html.TextArea("CommentsToAdd", string.Empty, 10, 55, null) %>

かみそりの使用:

@Html.TextAreaFor(e => e.CommentsToAdd, 10, 55, null)
@Html.TextArea("CommentsToAdd", string.Empty, 10, 55, null) 

<textarea>これは (単一行) ではなく (複数行)としてレンダリングされます<input type="text" />

于 2013-04-16T00:43:32.947 に答える