开发者

validate DropdownlistFor help

I couldn't get this code working. It's not displaying validation error message开发者_如何学编程 when I submit the form.

viewModel

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

Create.aspx

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


Try this

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜