I would like to change the htmlAttributes of the code rendered by my Html.ValidationMessageFor
, but I want the message displayed to be the "default".
The overload options are:
A) Html.ValidationMessageFor(expression)
B) Html.ValidationMessageFor(expression, validationMessage)
C) Html.ValidationMessageFor(expression, validationMessage, htmlAttributesObject)
I wish there was a Html.ValidationMessageFor(expression, htmlAttributesObject)
option, but there is not.
How can I achieve the desired result with option C? That is, where is that "default" messages stored? Is there an clean, easy way to get at it, so I can plug it in to the validationMessage parameter?
Thanks
Since you don't want to override the default message, simply supply an empty string and MVC will use the default message:
<%: Html.ValidationMessageFor(m => m.propertyName, string.Empty, new { attribs ... }) %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With