Html 如何在asp.net mvc中创建多行文本框?
如何在asp.net mvc中创建多行文本框 可能不是特定于asp.net mvc的,但我正在使用它 这是我的Html 如何在asp.net mvc中创建多行文本框?,html,asp.net-mvc,Html,Asp.net Mvc,如何在asp.net mvc中创建多行文本框 可能不是特定于asp.net mvc的,但我正在使用它 这是我的 <%: Html.TextBox("CommentToAdd", null, new { @class = "input-medium", TextMode = "MultiLine", Columns = "55", Rows = "10", type = "text", required = "required" })%> 多行文本框只是一个文本区域 其中任何
<%: Html.TextBox("CommentToAdd", null, new
{
@class = "input-medium",
TextMode = "MultiLine",
Columns = "55",
Rows = "10",
type = "text",
required = "required"
})%>
多行文本框只是一个文本区域 其中任何一个都应该有效
<%= Html.TextArea("Body", null, new { cols = "100", rows = "5" }) %>
<%= Html.TextArea("Body", null, 5, 100, null) %>
<%= Html.TextAreaFor(x => x.Body, 5, 100, null) %>
x、 正文,5100,空)%%>
我认为MVC中的多行textbox
是textarea
<%= Html.TextArea("Body", null, new { cols = "55", rows = "10" }) %>
或
x.Body,10,55,null)%>
您希望使用文本区域,而不是文本框。用于将其绑定到模型,否则使用
这将被呈现为
(多行)而不是
(单行)。只需将此属性添加到属性
[DataType(DataType.MultilineText)]
public string CommentsToAdd{ get; set; }
如果您正在回答一个问题,请更具体地解释您的答案,以便对其他人也有帮助。如果您使用的是EditorFor(),则DataType.MultilineText会完成此工作!太好了,谢谢。
<%= 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)
[DataType(DataType.MultilineText)]
public string CommentsToAdd{ get; set; }