title: Single quote escape character encoding to &#39 ; inside javascript
body: <p>I have been testing all the different ways to create an interactive google map with markers from my database. I'm pretty close using the javascript API. It's placing the markers fine but when it goes to create the labels I need to escape character ' and somewhere it's getting encoded to &amp;#39 ; which kills the javascript. I've tried several ways to decode like HtmlDecode(string) and $("").html(name).text(); but none worked. How can I prevent encoding or somehow decode inside the javascript?</p>
  
  <p>This is the map code</p>
  
  <pre><code>&lt;script&gt;
  var map;
  function initialize() {
      // Create a simple map.
      map = new google.maps.Map(document.getElementById('map'), {
          zoom: 8,
          center: { lat: 32.9393, lng: -117.0437 },
          mapTypeId: google.maps.MapTypeId.TERRAIN
      });
  
      @siNetWebApplication.Models.siNetWebHelperFunctions.mapGetMarkers(Model.Runs.ToList())
  
      }
  
  google.maps.event.addDomListener(window, 'load', initialize);
  </code></pre>
  
  <p></p>
  
  <p>This is the mapGetMarkers() function that builds the list of map markers</p>
  
  <pre><code>public static string mapGetMarkers(List&lt;AverageNodeValues&gt; runs)
      {
          decimal zero = 0;
          var count = 0;
          var limit = 20;
          List&lt;string&gt; usedNodes = new List&lt;string&gt;();
          StringBuilder builder = new StringBuilder();
  
          foreach (AverageNodeValues run in runs)
          {
              if (!usedNodes.Contains(run.NodeID))
              {
                  if (run.GPS_Lattitude != zero &amp;&amp; run.GPS_Longitude != zero)
                  {
                      builder.Append("var marker")
                          .Append(run.NodeID)
                          .Append(" = new google.maps.Marker({ position: { lat: ")
                          .Append(run.GPS_Lattitude)
                          .Append(", lng: ")
                          .Append(run.GPS_Longitude)
                          .Append(" }, map: map }); ")
                          .Append("var info")
                          .Append(run.NodeID)
                          .Append(" = new google.maps.InfoWindow({ content: ")
                          .Append("\'")
                          .Append(run.NodeID)
                          .Append("\'")
                          .Append(", ")
                          .Append("\'")
                          .Append(@"click")
                          .Append("\'")
                          .Append(", function () { info")
                          .Append(run.NodeID)
                          .Append(".open(map, marker")
                          .Append(run.NodeID)
                          .Append("); }); ");
                      usedNodes.Add(run.NodeID);
                      count++;
                  }
                  if (count &gt;= limit)
                  {
                      break;
                  }
              }
          }
          return builder.ToString();
      }
  </code></pre>
  
  <p>And this is what ends up in the html</p>
  
  <pre><code>var markerG0000112 = new google.maps.Marker({ position: { lat: 29.5672500000, lng: -98.2429816666 }, map: map }); var infoG0000112 = new google.maps.InfoWindow({ content: &amp;#39;G0000112&amp;#39;, &amp;#39;click&amp;#39;, function () { infoG0000112.open(map, markerG0000112); }); var markerG0000113 = new google.maps.Marker({ position: { lat: 29.5672566666, lng: -98.2419316666 }, map: map }); var infoG0000113 = new google.maps.InfoWindow({ content: &amp;#39;G0000113&amp;#39;, &amp;#39;click&amp;#39;, function () { infoG0000113.open(map, markerG0000113); }); var markerG0000102 = new google.maps.Marker({ position: { lat: 32.9393233333, lng: -117.0437383333 }, map: map }); var infoG0000102 = new google.maps.InfoWindow({ content: &amp;#39;G0000102&amp;#39;, &amp;#39;click&amp;#39;, function () { infoG0000102.open(map, markerG0000102); });
  </code></pre>