gpt4 book ai didi

twitter-bootstrap - @Html.PasswordFor 不参加 Bootstrap 类

转载 作者:行者123 更新时间:2023-12-04 07:43:39 28 4
gpt4 key购买 nike

我有以下用于显示文本框和密码的 Razor 代码

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

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

但是,在渲染时,文本框的外观与密码文本框不同。为什么当两者的类(class)相同时?

上面两行之间没有任何 css 引用,所以想知道不一致。

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

谢谢

enter image description here

最佳答案

更改 @Html.PasswordFor 的语法到我在下面显示的内容,它将正确应用您的类(class)。

@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 .

关于twitter-bootstrap - @Html.PasswordFor 不参加 Bootstrap 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39710671/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com