好的,我已经为字符串定义了一个共享编辑器,如下所示
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<%= Html.LabelFor(model => model) %>
<%= Html.TextBoxFor(model => model) %>
<%= Html.ValidationMessageFor(model => model) %>
现在我在另一个控件中像这样调用自定义编辑器
<%= Html.EditorFor(model=>model.Username)%>
<%= Html.EditorFor(model=>model.Email)%>
<%= Html.EditorFor(model=>model.Password)%>
我的模型是这样的
[Required(ErrorMessage="Le nom d'utilisateur est requis.")]
[DataType(DataType.Text)]
[DisplayName("Nom d'utilisateur")]
public string Username { get; set; }
[Required(ErrorMessage = "L'email est requis.")]
[DataType(DataType.EmailAddress)]
[DisplayName("Courriel")]
public string Email { get; set; }
[Required(ErrorMessage = "Le mot de passe est requis.")]
[ValidatePasswordLength]
[DataType(DataType.Password)]
[DisplayName("Mot de passe")]
public string Password { get; set; }
呈现的唯一显示是电子邮件字段。另外两个没有渲染?如果我删除 DataType.Text 和 DataType.Password 那么所有的显示字段都被渲染了??
很奇怪的行为...
有人知道为什么吗?