[英]How can I access the model properties from extended attribute when using textboxfor?
从概念上讲,我希望以下代码可以工作:
@Html.TextBoxFor(x => x.Something, null, new {
@class = "custom",
data_min = x.min,
data_max = x.max,
data_step = x.step
})
当然,我似乎无法从扩展属性部分访问属性min
, max
等。
我该如何实现呢?
谢谢。
只需使用Model
:
@Html.TextBoxFor(
x => x.Something,
new {
@class = "custom",
data_min = Model.min,
data_max = Model.max,
data_step = Model.step
}
)
将此属性添加到模型中
public IDictionary<string, object> Attributes { get; set; }
然后
@Html.TextBoxFor(model => model.SomeValue, Model.Attributes)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.