Search code examples
javascriptasp.net-mvc-3resource-files

Resource file variable giving string ASCII code issues in js alert box


I have a variable in a resource file (.resx), the value having the word you'd.

When I try to use this variable directly in an alert box it displays you'd as you'd.

What could be the issue? and how do I resolve it?


Solution

  • Try this:

    alert('@System.Web.HttpUtility.JavaScriptStringEncode("Hello, You'd like this.")');