MVC3 HTML.TextAreaFor 的默认值
我有一个 html.TextArea 助手,我想设置默认值。
@Html.TextAreaFor(model => model.CompletionCriteria,
new { rows = 5, cols = 70, @class = "celltext2",
@Value = ViewBag.CompletionCriteria,
@Text = ViewBag.CompletionCriteria })
控制器通过查询 DBContext 来设置 ViewBag.CompletionCriteria 变量,以获取给定 TextArea 的默认值。 TextArea Value 和 Text 属性设置正确,因此 ViewBag 很好,但数据不会显示在 TextArea 中。我确信我只是缺少一个属性设置。有什么想法吗?
I have an html.TextArea helper that I'd like to set a default.
@Html.TextAreaFor(model => model.CompletionCriteria,
new { rows = 5, cols = 70, @class = "celltext2",
@Value = ViewBag.CompletionCriteria,
@Text = ViewBag.CompletionCriteria })
The controller is setting the ViewBag.CompletionCriteria variable by querying the DBContext to get the default vaule for this given TextArea. The TextArea Value and Text properties are being set correctly, so the ViewBag is good, however the data doesn't display in the TextArea. I'm sure I'm just missing a property setting. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
删除@Value 和@Text 属性。假设它设置正确并且您没有使用强类型模型,它将自动填充它。确保它在视图和控制器中拼写正确。
Remove the @Value and @Text attributes. It will automatically populate it, assuming it's set correctly and you're not using a strongly typed model. make sure it's spelled correctly in both your View and Controller.
在控制器中,
在 HTML
对于自定义属性中,您可以使用 data_mask 示例,
它将呈现为 data-mask ="phone"
In controller
In HTML
For Custom Attributes you can use like data_mask sample
it will render like data-mask ="phone"