相关疑难解决方法(0)

使用DataAnnotations和DataType进行电子邮件模型验证

我有以下型号:

public class FormularModel
{
    [Required]
    public string Position { get; set; }
    [Required]
    [DataType(DataType.EmailAddress)]
    public string Email { get; set; }
    [Required]
    public string Webcode { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

必需的验证工作正常.但是当我尝试使用DataType时它没有反应.

这是我的电子邮件控件的剃刀代码:

   @Html.TextBoxFor
          (model => model.Email, 
           new { @style = "width: 175px;", @class = "txtField" }
          ) * 
Run Code Online (Sandbox Code Playgroud)

那么,有人知道答案吗?

TIA

c# email validation asp.net-mvc model

51
推荐指数
2
解决办法
8万
查看次数

标签 统计

asp.net-mvc ×1

c# ×1

email ×1

model ×1

validation ×1