MVC View端设置只读

1.下拉框设为只读试了试用这个有效:

  @Html.DropDownListFor(model => model.SecondDevelopment, (SelectList)ViewBag.swseconddevelopment, new { disabled = "disabled" })

2.文本框:

 @Html.TextBoxFor(model => model.ProjectLeaderName, new { @readonly = "readonly" })

3.多选框

  @Html.CheckBoxListFor(model => model.ProvideService, (SelectList)ViewBag.swprovideservice,null, new { @readonly = true })


4.单选按钮

 @Html.RadioButtonListFor(model => model.NeedApply, (SelectList)ViewBag.swneedapplyornot, null, new { disabled = "disabled" })

 

备注:设置只读不要用 disabled = "disabled",效果是只读效果,但是后端获取数据时会获取不到该字段的数据。

posted @ 2017-10-19 16:29  看那一叶春风  阅读(465)  评论(0)    收藏  举报