title: If filename has single quote C# javascript does not get executed
body: <p>I need to pass a URL from C# to javascript. The problem is if the filename has single quote, it does not execute the javascript. When I use HttpUtility.HtmlEncode(fileNameWithoutEx) it does execute javascript but if filename is say "Copy of David's Birth Certificate" then URL gets converted to ?View.aspx?length=60&amp;ext=pdf&amp;file=Copy of David&amp;#39; Birth Certificate. </p>
  
  <p>When View.aspx tries to get the querystring file i.e; filename, it gets set to "Copy of David" and not "Copy of David's Birth Certificate". Because of &amp; it does not get the rest of the querystring. </p>
  
  <pre><code> if (System.IO.File.Exists(fileLocation)) {
              string fileNameWithoutExt = System.IO.Path.GetFileNameWithoutExtension(fileLocation);
              string fileExtension = System.IO.Path.GetExtension(fileLocation).Replace(".", "");
              string title = System.IO.Path.GetFileNameWithoutExtension(fileName);
              string url = "View?length=" + 60+ "&amp;ext=" + fileExtension + "&amp;file=" + fileNameWithoutExt;
              ScriptManager.RegisterStartupScript(this, GetType(), "ShowPDF", "$(document).ready(function(){ShowPDFDocument('" + title + "', '" + url + "');});", true);                                      
  }                                       
  </code></pre>
  
  <p>How can I send url with single quote to javascript?</p>
  
  <p>What's the best way to handle ' and other special characters?</p>