The Html.TextBox
syntax is:
public static MvcHtmlString TextBox(this HtmlHelper htmlHelper, string name,
object value, object htmlAttributes);
So, i put my data attribute in htmlAttributes
. I have tried
@Html.TextBox("date",Model.Date,new { data-myid="aaa"})
but that doesn't work for me.
Try using underscore _
character.
@Html.TextBox("date",Model.Date,new { data_myid="aaa"})
The runtime will convert that to data-myid
For a friendlier syntax, you could try: http://buildmvc.codeplex.com/
@Html.BuildTextBox("date", Model.Date).Data("myid", "aaa")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With