Hala Aly
Hala Aly

Reputation: 141

Display required attribute message as html text in mvc3

I has required field like this

[Required(ErrorMessageResourceName = "AddCategoryCodeRequiredError", ErrorMessageResourceType = typeof(Resources.Category.Category))]
public string CategoryCode { get; set; }

and the error message in the resource file like this

<b>Required Field Missing</b> A code is required.

when the error displayed in the page the message part

<b>Required Field Missing</b> 

displayed as is not as bold text.

how can I display the message as html??

Upvotes: 2

Views: 950

Answers (1)

Darin Dimitrov
Darin Dimitrov

Reputation: 1039438

The Html.ValidationSummary helper is designed to HTML encode the error message. This basically means that you cannot use HTML tags inside your error messages. If you wanted to do so you will have to write a custom helper to display it which doesn't perform encoding. Here's an example with a custom validation summary helper. The same is true for the ValidationMessageFor helpers.

Upvotes: 4

Related Questions