Reputation: 1629
I have a property on my viewmodel of type int?
/// <summary>
/// Represents A company Id
/// </summary>
[Range(1, 999999999, ErrorMessage="Error"])
public int? CompanyId{ get; set; }
From the textbox I user enter a big number that overflows int32
maxValue, then I think
an internal validation exception is thrown but the message doesn't appear.
I am overriding default messages in global.asax
by calling:
DefaultModelBinder.ResourceClassKey = "GlobalResources";
Do you know what key I should enter to override resources so that the message will appear? Is there any specific message for Int32
overflow?
I've overridden the PropertyValueInvalid
but it doesn't show. It seems like there is another key that need to be overridden. Please point me where can I find all list of default keys.
Upvotes: 3
Views: 1655
Reputation: 6144
You need to add @Html.ValidationMessageFor(model => model.CompanyId)
to your view so the validation message actually shows. Otherwise you will only get a red
border on your textbox, as you mentioned.
Upvotes: 1