Cha*_*ell 2 textarea asp.net-mvc-2
我正在尝试使TextArea具有默认值.
<%: Html.TextAreaFor(Function(model) model.Description, 5, 10, New With {.Value = "Description: "})%>
Run Code Online (Sandbox Code Playgroud)
这在a TextBoxFor中正常工作但在a中不起作用TextAreaFor
我错过了很明显的东西吗?
您可以在创建模型时在控制器操作中指定Description属性的值,并将该模型传递给View:
public ViewResult Create()
{
var model = new MyPageModel()
{
Description = "Description: ";
}
return View(model);
}
Run Code Online (Sandbox Code Playgroud)
在视图中:
<%: Html.TextAreaFor(model.Description) %>
Run Code Online (Sandbox Code Playgroud)
设置值将不起作用,因为在开始和结束标记之间指定TextArea的内容,而不是作为属性.
| 归档时间: |
|
| 查看次数: |
6353 次 |
| 最近记录: |