加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

twitter-bootstrap – @ Html.Password不参加bootstrap课程

发布时间:2020-12-17 21:22:02 所属栏目:安全 来源:网络整理
导读:我有以下剃刀代码用于显示文本框和密码 @Html.EditorFor(model = model.LoginName,new { htmlAttributes = new { @class = "form-control" } }) @Html.PasswordFor(model = model.LoginPassword,new { htmlAttributes = new { @class = "form-control" } })
我有以下剃刀代码用于显示文本框和密码

@Html.EditorFor(model => model.LoginName,new { htmlAttributes = new { @class = "form-control" } })

 @Html.PasswordFor(model => model.LoginPassword,new { htmlAttributes = new { @class = "form-control" } })

但是,渲染时,文本框的外观与密码文本框不同.为什么两个班级相同?

上面两行之间没有任何css参考,所以对这种不一致感到疑惑.

有人遇到过这个问题吗?我不想为密码文本框写一个自定义的CSS,它看起来像用户名文本框.

谢谢

enter image description here

解决方法

将@ Html.PasswordFor的语法更改为我在下面显示的内容,它将正确应用您的课程.

@Html.EditorFor(model => model.LoginName,new { htmlAttributes = new { @class = "form-control" } })

@Html.PasswordFor(model => model.LoginPassword,new { @class = "form-control" })

原因是second argument for EditorFor is object additionalViewData,其中second argument for PasswordFor is object htmlAttributes.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读