【发布时间】:2017-11-14 02:27:07
【问题描述】:
如果用作EditorFor(x=> x, new {htmlAttributes = new {@class = "x"}}),则EditorFor 帮助器可用于自动构建模型。问题是,由于它会自动生成标签、字段和验证消息,是否可以为传递给此方法的匿名类型中的每个元素自定义样式和类 (new { htmlAttributes = ..})?
【问题讨论】:
-
你对
new { htmlAttributes = new {@class = "x" }}有什么要求,你想从viewmodel属性或ViewBag动态改变类'x'? -
@TetsuyaYamamoto:不,
EditorFor能够与模型的各个成员一起搭建整个模型。自动脚手架时,我们如何为标签('text-danger')、字段('form-control')、验证('validation-error')等每种脚手架项目定义css类?
标签: asp.net-mvc asp.net-core-mvc html-helper