bb2
bb2

Reputation: 2982

Customize required attribute

I've been trying to custumize the required attribute using this solution

But I get that I'm missing a directive with:

ErrorMessageResourceType = typeof(Resources.ValidationErrors);
ErrorMessageResourceName = "Required";

ErrorMessageResourceType and ErrorMessageResourceName. What else do I need to make this work?

Upvotes: 0

Views: 1289

Answers (1)

Buildstarted
Buildstarted

Reputation: 26689

They're both properties of the ValidationAttribute in the System.ComponentModel.DataAnnotations dll. So you might need a reference there but you wouldn't get the Required attribute so it might be something else

If you're using VB and not c# then you'll have to type:

<Required(ErrorMessageResourceType := GetType(Resources.ValidationErrors),
          ErrorMessageResourceName := "Required")>

The c# one should look like:

[Required(ErrorMessageResourceType = typeof(Resources.ValidationErrors),
          ErrorMessageResourceName = "Required")]

Can you post your whole code for your Required attribute so that we can narrow it down?

Upvotes: 1

Related Questions