cam*_*ron 13 asp.net asp.net-mvc razor asp.net-mvc-3
该Html.TextBox语法是:
public static MvcHtmlString TextBox(this HtmlHelper htmlHelper, string name,
object value, object htmlAttributes);
Run Code Online (Sandbox Code Playgroud)
所以,我把我的数据属性放入htmlAttributes.我试过了
@Html.TextBox("date",Model.Date,new { data-myid="aaa"})
Run Code Online (Sandbox Code Playgroud)
但这对我不起作用.
sca*_*tag 24
尝试使用下划线_字符.
@Html.TextBox("date",Model.Date,new { data_myid="aaa"})
Run Code Online (Sandbox Code Playgroud)
运行时将其转换为 data-myid