title: How to pass Server.HtmlEncode in ajax jquery method
body: <p>I am using Server.HtmlEncode </p>
  
  <p>to Encode the string, since  it is not support apostrophe </p>
  
  <pre><code>Example-"Capacit's Infraprojects Limited" changes  to 
   "Capacit&amp;amp;#39;e" Infraprojects Limited &lt;br&gt;
  So I used  Server.HtmlEncode to resolve it 
  
   &lt;a onclick="setOfferDocument('@Server.HtmlEncode(documents.CompanyName)')"  class="link-download" href="javascript:void(0)" 
   &gt;@Server.HtmlDecode(documents.CompanyName)&lt;/a&gt;
  </code></pre>
  
  <p>Now I have dropdown where on click of company name it fetch the data
  For that I using the ajax function </p>
  
  <p>dropdown-</p>
  
  <pre><code>&lt;select id="single-appendSpeaker" onchange="GetSelectedOfferData()" class="select2" style="width:;"&gt;    
              &lt;option value="All"&gt;All&lt;/option&gt;       
                           &lt;/select&gt;     
  </code></pre>
  
  <p>Ajax function Where I get the name of comapny </p>
  
  <pre><code>function GetSelectedOfferData() {
      debugger;
          var companyName = $("#single-appendSpeaker").val();
          if (companyName == "All") {
              $.ajax({
                  type: "POST",
                  dataType: "json",
                  url: "/OfferDocument/getAllOfferDocument",
                  data: {},
                  success: function (result) {
                      var doc = '';
  
  
                      $.each(result, function (i, val) {
                          doc = doc + '&lt;li&gt;&lt;a onclick="setOfferDocument(\'' + val.companyName  + '\')"  class="link-download" href="javascript:void(0)" &gt;' + val.companyName  + '&lt;/a&gt;&lt;br /&gt;&lt;/li&gt;'
                      });
                      $("#ProspectUL").empty();
                      $("#ProspectUL").append(doc);
                  }
              });           
           }
          else {
              var data = '';    
  
              data = data + '&lt;li&gt;&lt;a onclick="setOfferDocument(\'' + companyName  + '\')"  class="link-download" href="javascript:void(0)" &gt;' + companyName + '&lt;/a&gt;&lt;br /&gt;&lt;/li&gt;'
              $("#ProspectUL").empty();
              $("#ProspectUL").append(data);           
          }
      }
  </code></pre>
  
  <p>Now since the name is not matching I am not getting the value,
  for that i need to encode this value<br>
  eg- Capacit's Infraprojects Limited to Capacit&amp;#39;e" Infraprojects Limited</p>
  
  <p>Then only it will match and I will get the data...</p>
  
  <p>I tried to </p>
  
  <pre><code> doc = doc + '&lt;li&gt;&lt;a onclick="setOfferDocument(\'' + @Server.HtmlEncode(val.companyName)  + '\')"  class="link-download" href="javascript:void(0)" &gt;' +@Server.HtmlEncode(val.companyName)  + '&lt;/a&gt;&lt;br /&gt;&lt;/li&gt;'
                          });
  </code></pre>
  
  <p>Not Working </p>