开发者

validate DropdownlistFor help

开发者 https://www.devze.com 2023-01-30 03:29 出处:网络
I couldn\'t get this code working. It\'s not displaying validation error message开发者_如何学编程 when I submit the form.

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

精彩评论

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