加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

.NET MVC屏蔽密码文本框

发布时间:2020-12-15 23:04:44 所属栏目:asp.Net 来源:网络整理
导读:我的印象是使用如下注释: Required()DisplayName("Choose a Password:")ValidatePasswordLength()DataType(DataType.Password)Public Property Password As String 在视图中使用时会创建一个蒙版字段: %: Html.TextBoxFor(Function(model) model.Password)
我的印象是使用如下注释:
<Required()>
<DisplayName("Choose a Password:")>
<ValidatePasswordLength()>
<DataType(DataType.Password)>
Public Property Password As String

在视图中使用时会创建一个蒙版字段:

<%: Html.TextBoxFor(Function(model) model.Password) %>
<%: Html.ValidationMessageFor(Function(model) model.Password) %>

但是,这是不用type =“password”

什么是“DataType.Password”用于,如果不是这样?

解决方法

您正在使用Html.TextBoxFor,它总是输出< input type =“text”>标记在生成的HTML中.
如果你想要DataType.Password注释被自动兑现,你应该使用Html.EditorFor代替.
您可以在这里阅读更多关于编辑器模板和如何自定义它们: http://bradwilson.typepad.com/blog/2009/10/aspnet-mvc-2-templates-part-1-introduction.html

(编辑:李大同)

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

    推荐文章
      热点阅读