在传统webForm中,输入框的这样的:

<input id="userName" name="userName" type="text" value="" />

而在mvc中,可以写成这样

@Html.TextBoxFor(m => m.userName)

那么如何在mvc中的@Html.TextBoxFor(m => m.userName)输入框添加css样式呢?

@Html.TextBoxFor(m => m.userName,new {@class="main",@style="width:20px;"})

上面一句就等于

<input class="main" id="userName" name="userName" style="width:20px;" type="text" value="" />

 

添加自定义样式

@Html.TextBoxFor(model => model.InputNumber, new {@style="width:30px;border:1px solid red"})

添加属性

@Html.TextBoxFor(model => model.InputNumber, new { @class="Names"})

相关文章:

  • 2022-12-23
  • 2021-08-29
  • 2021-12-26
  • 2021-08-03
  • 2021-12-20
  • 2021-12-02
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-15
相关资源
相似解决方案