Hello I have this code in my ASP.NET Razor v2 cshtml file that should load string into this paragraph the variable is from c# list of strings but when the string that is loaded contains something like this:
+ "<p>"+'Rejvízská 113 79001 Jeseník'+"</p>"
I get this JavaScript critical error: SCRIPT1015: Unterminated string constant
The program fails because some character escaped my ending quotation mar '
Actually the code looks like this:
"<p>"+'@string.Format(serviceDescription[i])'+"</p>"
serviceDescription is list of strings that may containt whatever value that can escape my ' character.
May I please know how to correct this?
This code is used in adjusting InfoWindow in Google API
So far I tried and non of these method worked:
  + "<p>"+' @string.Format("<p>{0}</p>", serviceDescription[i])'+"</p>"
  + "<p>"+'@string.Format(serviceDescription[i])'+"</p>"
  + "<p>"+'@string.Format("{0}", @Html.Raw(serviceDescription[i]))'+"</p>"
  + "<p>"+' @(new HtmlString(serviceDescription[i]))'+"</p>" 
  + "<p>"+' @Html.Raw(serviceDescription[i])'+"</p>"
  + ' @Html.Raw("<p>"+@serviceDescription[i]+"</p>")'
  "<p>" @Html.Raw(String.Format(serviceDescription[i]))+"</p>"
  + @(new HtmlString("<p>"+serviceDescription[i]+"</p>"))
My whole InfoWindow code:
  var info = new google.maps.InfoWindow({
            map: map
        });
        /*   <img src="data:image/jpeg;base64{binary data}" />   */
        google.maps.event.addListener(marker, 'click', function () {
            var $infoWindowContent = $("<div style='line-height:1.35;overflow:hidden;white-space:nowrap;width: 200px'><h3>" + '@serviceTitle[i].ToString()'
                + '</h3><img src=@string.Format("data:{0};base64,{1}", serviceImgMIME[i], Convert.ToBase64String(serviceImgBinary[i])) style="width: 100%;max-height: 100%"/>'
                + "<p>"+ @Html.Raw(String.Format("{0}",serviceDescription[i]))+"</p>" // this is the line that causes me pain
                + "Web: " + "<a href="+'http://@string.Format("{0}", serviceLink[i])'+">"+'@serviceLink[i].ToString()'+"</a>"
                + "<br>"
                + "Kontakt: "+ "<a href="+'mailto:@serviceContact[i].ToString()'+">"+'@serviceContact[i].ToString()'+"</a>"
                + "<p>"+"Lze platit v: "+"<b>"+'@serviceIDCryptoCur[i].ToString()'+"</b>"+"</p>"
                + @switch (serviceIDCryptoCur[i])
                  {
                      case "BTC": 
                <text>
                '<img height="20" width"20" src="~/Content/ikonky/btcSmall.png">'
            </text>
                          break;
                      case "LTC": 
                <text>
            '<img height="20" width"20" src="~/Content/ikonky/ltcSmall.png">'
            </text>
                          break;
                      case "BTC,LTC":
        <text>
            '<img height="20" width"20"  src="~/Content/ikonky/ltcSmall.png"> <img height="20" width"20"  src="~/Content/ikonky/btcSmall.png">' 
        </text>
                          break;
                      default:
        <text>
                '<img height="20" width"20"  src="~/Content/ikonky/btcSmall.png">'
        </text>
                          break;
                  }
                + "</div>");
            info.setContent($infoWindowContent[0]);
            info.open(map, this);
        });
 
     
    
{0}
", serviceDescription[1])`. If not, my bad ... – Tim Vermaelen Nov 28 '13 at 19:15{0}
",serviceDescription[i])) – Grundy Nov 28 '13 at 20:16"+'@string.Format(serviceDescription[i])'+"
"` – YK1 Nov 28 '13 at 20:24"+'@string.Format(serviceDescription[i])'+"
"` – Marek Nov 28 '13 at 21:05