jwillmer
jwillmer

Reputation: 3789

Where is the Magic in the Validation?

In my RazorView i use:

@Html.Editor(prop.PropertyName)

to get the EditorForm. It also creates the Tags: data-val-* with Validationmessages. But in this auto generated Validationmessages the variablename is shown as type.

data-val-number="The field "Int32" must be numeric."

I think this is because the object that cames to the Validationfunction misses the variablename and so he uses the type. So I need to know where the function tries to get the variablenname or which field the function tries to read to fix this.

p.s. I realy don´t want to change my previous code to fix this, it has his reasons why it is like it is ;-)

Upvotes: 0

Views: 78

Answers (1)

Chris Snowden
Chris Snowden

Reputation: 5002

The variable name will default to the Property name unless you add a [DisplayName("New Name")] attribute to the Property to change the name used. What type is prop in your example?

Upvotes: 1

Related Questions