I am using MVC 3 and I am trying to exclude some fields from validation in the create action.
I see some examples showing how to exclude fields using [ValidateInput (true, Exclude = "xxxx")], but when I try to do this, I get this error:
"ValidateInputAttribute does not contain a definition for Exclude"
Any thousands?
Edit:
I have a partial class that looks like this:
[MetadataType(typeof(Article_Validation))]
public partial class article
{
}
public class Article_Validation
{
[HiddenInput(DisplayValue = false)]
public int article_id { get; set; }
[Required(ErrorMessage = "Title is required")]
public string article_title { get; set; }
[AllowHtml]
[Required(ErrorMessage = "Body is required")]
public string article_body { get; set; }
[HiddenInput(DisplayValue = false)]
public DateTime article_datecreared { get; set; }
[HiddenInput(DisplayValue = false)]
public DateTime article_datemodified { get; set; }
[HiddenInput(DisplayValue = false)]
public int article_viewcount { get; set; }
[AllowHtml]
[Required(ErrorMessage = "Abstract is required")]
public string article_abstract { get; set; }
}
[AllowHtml] fits into two properties, but I still get the error. I was under the impression that this class will be "merged" with an EF class with the same name?
If I put [ValidateInput (false)] on the controller, it works fine.