Reputation: 262
I have an MVC Application wherein on page load I am initializing javascript function call with a Model value received from the server.
Something like this :
myFunction('@Model.ServerUnicodeCharacters');
Now, when I set to value
Model.ServerUnicodeCharacters = 'Côte d'Ivoire'
Inside javascript I get "C ô ;te d' ;Ivoire"
(Intentionally added space before semicolon to show the output)
Is there any way to skip this character encoding which is default in ASP.NET MVC?
Upvotes: 0
Views: 59
Reputation: 171
try replacing:
myFunction('@Model.ServerUnicodeCharacters');
with:
myFunction('@Html.Raw(Model.ServerUnicodeCharacters)');
Taken from MSDN:
The Razor syntax @ operator HTML-encodes text before rendering it to the HTTP response. This causes the text to be displayed as regular text in the web page instead of being interpreted as HTML markup.
Upvotes: 1