1

我无法让这段代码工作。当我提交表单时,它没有显示验证错误消息。

视图模型

    [Required] 
    public SelectList CountryList { get; set; }
    public string Country { get; set; }

创建.aspx

    <%= Html.DropDownListFor(m => m.Country,Model.CountryList, "--Select--")%>
        <%: Html.ValidationMessageFor(model => model.Country,"*") %>
4

1 回答 1

2

Try this

public SelectList CountryList { get; set; }
[Required]  
public string Country { get; set; }
于 2010-12-13T19:51:59.233 回答