1

I am working on a MVC project. I have model called person whose attributes are Name and Country. in my model i have used [DisplayName("Name")] public string Name{ get; set; }

I want that if Country is England DisplayNAme should be Name , if country is Netherlands then Display name should be Naam.

In short can we make DisplayName conditional in model itsefl? or can we assign more than one displayname to attribute??

1 Answer 1

3

Yes, add a resource file for each language with a key of Name. You can then decorate your class Properties with something like this:

[Display(Name = "Name", ResourceType = typeof(MyResources))]

Further details on Display can be found here, and localization and MVC in general here.

Sign up to request clarification or add additional context in comments.

1 Comment

Ok, I've done that. I think you get more reputation for accepting an answer too...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.