I was under the impression that using an annotation like this:
<Required()>
<DisplayName("Choose a Password:")>
<ValidatePasswordLength()>
<DataType(DataType.Password)>
Public Property Password As String
Would create a masked field when used in the view:
<%: Html.TextBoxFor(Function(model) model.Password) %>
<%: Html.ValidationMessageFor(Function(model) model.Password) %>
However this is rendered without the type=”password”
What is the “DataType.Password” used for if not this?
You are using
Html.TextBoxForwhich always outputs an<input type="text">tag in the resulting HTML.If you want the DataType.Password annotation to be automatically honored you should use
Html.EditorForinstead.You can read more about editor templates and how to customize them here: http://bradwilson.typepad.com/blog/2009/10/aspnet-mvc-2-templates-part-1-introduction.html