使用MVC 4,我为带有“数据消息”属性的模型属性创建了一个文本框:
@Html.TextBoxFor(o => o.TradeOrder.Symbol, new {data-message="Required"})
但是,出现以下错误:
Invalid anonymous type member declarator. Anonymous type members must be declared with a member assignment, simple name or member access.
最佳答案
使用_
:
@Html.TextBoxFor(o => o.TradeOrder.Symbol, new {data_message="Required"})
TextBoxFor帮助程序将知道该怎么做,并在生成标记时将其替换为
-
。
关于asp.net-mvc - ASP.NET MVC将属性 “data-message”添加到Html.TextBoxFor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19596232/