views:

59

answers:

1

I'm working on a CMS system which uses a resource file to get information and errormessages from. The client side validation is working without problems, only it's not getting the errormessage from the resource file. While debugging i figured out xval seems to get the errormessages from a javascript file where the messages are set hard-coded. Is there some way to override this?

Below the code which should make the relation to the resourcefile en specify the error when the field is left empty.

[Property]
    [Required(ErrorMessageResourceType = typeof(CMSMessages), ErrorMessageResourceName = "EnterValidMoney")]
    public virtual Double ShippingCost { get; set; }
A: 

xVal comes with a bunch of message JS files (in the Optional/Internationalization folder) but there appears to be no documentation on how to use them!

It looks like you simply need to include a <script src="..."> block after the min library is inluded.

Daniel Renshaw
i'm aware of that, i just upgraded from version 0.8 to 1.0 and saw they were new. But i didn't implement them, so these JS files aren't used.
Rob
You could create your own handler (ASHX or JS response MVC action) that emits the strings from your resource files in the same JS format and reference that instead.
Daniel Renshaw
Thanks for the tip! Gave me an idea to try something with an old customwritten js resourcefile a colleque written a few months ago :-)
Rob
I indeed can use the JS files as resources. But what i want is to use .NET resource files (.resx) Any idea how i can reference those? Or override the standard JS resources which are being used?
Rob
I meant that you could emit your own JS fle that is generated on the server-side on demand (though caching would be a good idea) by an ASP.NET HTTP handler which extracts the data from your existing standard .NET assembly resource file(s). Alternatively, this could be done by a batch application that generated the JS file whe the site is deployed.
Daniel Renshaw