In the following HTML + C# line:
<button type="button" onclick="Update(this, @Model.Quantity, '@Html.Raw(HttpUtility.JavaScriptStringEncode(order.Notes))')">Click Me<button>
the HttpUtility.JavaScriptStringEncode
does not encode double quotes which breaks the function call. So, I have add .Replace("\"",""")
to it:
@Html.Raw(HttpUtility.JavaScriptStringEncode(order.Notes).Replace("\"","""))
This works but why wouldn't the utility encode a double quote? Am I using it incorrectly or is it simply created that way?