When model is loaded/initiated for the first time the above custom attribute class is called successfully.
But if, I will post back the page then, it doesn't get called.
For example when I change my language from English to French. it still displays the English content.
Why it is so ? How can I solve this issue ? Can we load the
Model data explicitly
From your description, I'm not very sure about your issue. And, I also not sure about the meaning
of load the Model data explicitly. According to your code, I suppose the DisplayNameAttribute is used to get the display name. But, I don't know why it is related to change language?
So, I suppose perhaps you want to achieve change language function in your MVC application. If that is the case, I would like to suggest you set a break point to check your code
to see if there is anything breaking.
Here is a thread about change language in MVC Application, you could refer to it.
Participant
1847 Points
1340 Posts
Model in MVC
Oct 16, 2014 08:57 AM|rohitpundlik|LINK
Hello All,
I have written custom attribute for DisplayName as follows
When model is loaded/initiated for the first time the above custom attribute class is called successfully.
But if, I will post back the page then, it doesn't get called.
For example when I change my language from English to French. it still displays the English content.
Why it is so ? How can I solve this issue ? Can we load the Model data explicitly
Rohit Pundlik
Please mark as answer if this helps you...
Participant
890 Points
160 Posts
Re: Model in MVC
Oct 17, 2014 06:27 AM|Luther.Lv|LINK
Hi Rohit,
From your description, I'm not very sure about your issue. And, I also not sure about the meaning of load the Model data explicitly. According to your code, I suppose the DisplayNameAttribute is used to get the display name. But, I don't know why it is related to change language?
So, I suppose perhaps you want to achieve change language function in your MVC application. If that is the case, I would like to suggest you set a break point to check your code to see if there is anything breaking.
Here is a thread about change language in MVC Application, you could refer to it.
http://forums.asp.net/t/1723919.aspx?How+can+I+change+language+of+my+MVC+3+Application
Best Regards,
Luther