Note that there are some explanatory texts on larger screens.

plurals
  1. POasp.net mvc input / model validation multi language
    text
    copied!<p>I'm quite new to asp.net mvc, and right know I'm trying to find out a good practise to do input validation.</p> <p>In the project we're going to use entity framework, where you can add data annotations to properties in the following way:</p> <pre><code>[Required(ErrorMessage = "Please enter a product name")] [Column] public string Name { get; set; } </code></pre> <p>This is quite nice, however we have a multi language website (like most websites), so we can't only show the error messages in English. What can be a way to solve this? Can I change this errormessage @runtime, depending on the user's language? Should I use Jquery client side validation?</p> <p>Thanks for the input.</p> <p>Update I've tried the code on the website of Phil Haack This will do the trick with static resources however, we use resources that come from a database not static resources.</p> <p>If I fill in the following for the dataannotations:</p> <pre><code> [MetadataType(typeof(IncidentsMetaData))] public partial class INCIDENTS { private class IncidentsMetaData { [Required(ErrorMessageResourceType = typeof(CustomResourceProviders.DBResourceProviderFactory), ErrorMessageResourceName="1277")] public string SUBJECT { get; set; } } } </code></pre> <p>Then I get the following error: The resource type 'CustomResourceProviders.DBResourceProviderFactory' does not have an accessible static property named '1277'.</p> <p>Of course there is no such property, it should be accessed by a function. Any idea what I could do about this? tnx </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload