Hello, I need to replace the model state resource (to another language).
I've seen some answers to the question above, but unfortunately I could'nt make it work. Any detailed answer or example would be appriciated.
Thank you.
Hello, I need to replace the model state resource (to another language).
I've seen some answers to the question above, but unfortunately I could'nt make it work. Any detailed answer or example would be appriciated.
Thank you.
I don't know about v2, but this works on v1:
PropertyValueInvalid
and PropertyValueRequired
.System.Web.Mvc.DefaultModelBinder.ResourceClassKey = "resource file name"
.I can't get InvalidPropertyValue to work.
Here's the html:
<p>
<label for="Price">Price:</label>
<%= Html.TextBox("Price") %>
<%= Html.ValidationMessage("Price", "*") %>
</p>
Here's the code in the Global.asax:
protected void Application_Start()
{
RegisterRoutes(RouteTable.Routes);
DefaultModelBinder.ResourceClassKey = "MyResources";
ValidationExtensions.ResourceClassKey = "MyResources";
}
In MyResources.resx I enter "Invalid value" for InvalidPropertyValue.
However, when I run the program and enter hjhjhjhjh for Price, it still comes up with the asterisk (*) instead of the message.
I am trying to follow the book (ASP.NET MVC Unleashed) but for some reason it's not working for me.
I am using MVC 1, Visual Studio 2008 Standard Version.
Any ideas???
Got It.
In ASP.NET MVC 2 RC, It is PropertyValueInvalid, not InvalidPropertyValue.
Try using: <%= Html.ValidationMessage("Price") %> without the star "*".