I need to escape a double quote in inline c# within javascript. Code is below:
if ("<%= TempData["Message"]%>" == "") {
// code
};
Normally, I would just use single quotes like so:
if ('<%= TempData["Message"]%>' == "") {
// code
};
However, TempData["Message"]
has single quotes within it (when it contains a link generated by the Html.ActionLink() helper in ASP.NET MVC). So while I could change all the ActionLink helpers inside TempData["Message"]
to tags, it's an interesting problem and would been keen to hear if anyone has an answer.