确定我已经定义为串像以下ASP MVC 2 EditorFor奇怪的行为
<%@控制语言= “C#” 继承= “System.Web.Mvc.ViewUserControl” 共享编辑%>
<%= Html.LabelFor(型号=>模型)%>
<%= Html.TextBoxFor(型号=>模型)%>
<%= Html.ValidationMessageFor(型号=> 模型)% >
现在我打电话像这样的自定义编辑器中的另一个控制
<%= 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然后所有的显示字段被渲染?
很奇怪的行为...
有人知道为什么吗?
你能告诉我为什么你需要数据类型吗? – Stefanvds 2010-08-23 18:22:50
我可以走了,但为什么不呢? – mateo 2010-08-24 14:11:26