44

How can translate that line using TextBoxFor (MVC):

<input id="Name" name="Name" type="text" data-bind="value: Name" class="title width-7" />

Thanks

Paul
  • 12,359
  • 20
  • 64
  • 101

2 Answers2

92

MVC 3 will translate underscores in html attribute names into hyphens, so something like this should do the trick

@Html.TextBoxFor(m => m.Name, new { data_bind="value: Name", @class = "title width-7" })
Lukáš Novotný
  • 9,012
  • 3
  • 38
  • 46
12

For example,

if you want to add data-mask

@Html.TextBoxFor(m => m.BirthDate, new { @class = "form-control", data_mask = "date" })

it will generate in html

data-mask="date"
p.s.w.g
  • 146,324
  • 30
  • 291
  • 331
hasanaydogar
  • 885
  • 11
  • 24