我试图让 TextArea 具有默认值。
<%: Html.TextAreaFor(Function(model) model.Description, 5, 10, New With {.Value = "Description: "})%>
这可以正常工作在TextBoxFor
但不适用于TextAreaFor
我错过了一些非常明显的东西吗?
您可以在创建模型时在控制器操作中指定 Description 属性的值,并将该模型传递给视图:
public ViewResult Create()
{
var model = new MyPageModel()
{
Description = "Description: ";
}
return View(model);
}
视图中:
<%: Html.TextAreaFor(model.Description) %>
设置该值不起作用,因为 TextArea 的内容是在开始标记和结束标记之间指定的,而不是作为属性指定的。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)