0

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 &#244 ;te d&#39 ;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?

3

1 Answer 1

1

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.

MSDN Reference

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

Comments

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.