Chris Dixon
Chris Dixon

Reputation: 9167

MVC 4 EmailAddress - String EditorTemplate not being used

I've come across a strange issue including the [EmailAddress] DataAnnotation, say:

public string EmailAddress { get; set; }

With a EditorTemplate/String.cshtml works fine.

However:

[EmailAddress]
public string EmailAddress { get; set; }

This completely stops picking up the String.cshtml file, which is not ideal for my scenario. Any ideas out there as to why this is happening, and what I can do about it?

Upvotes: 3

Views: 924

Answers (1)

Hanno
Hanno

Reputation: 1027

Add a display template for EmailAddress, for an example how see here. There are also Nuget packages available that add display templates for all HTML5 input types.

Upvotes: 4

Related Questions