title: How to prevent HtmlGenericControl from html-encoding content?
body: <p>I'm writing an asp.net site (actually, a DotNetNuke module), using C#. From code-behind, I'm trying to create a <code>&lt;script&gt;</code> tag where I set a required js variable, then append it to the HMTL <code>&lt;head&gt;</code>. The js var is a (literal) array of relative urls for image files. Since the array contains strings, each item must be enclosed in quotes.</p>
  
  <p>The problem is, the string between <code>&lt;script&gt;</code> and <code>&lt;/script&gt;</code> is being automatically HtmlEncoded somewhere, so the quotes around each array item are being replaced with <code>&amp;quot;</code>. That seems to take place when the <code>HtmlGenericControl</code> is rendered. Could DotNetNuke be the culprit? Could someone suggest a workaround? </p>
  
  <p>My current code (running from <code>Page_Load</code> handler in my control):</p>
  
  <pre><code>HtmlGenericControl PreviewDataScriptTag = new HtmlGenericControl("script");
  PreviewDataScriptTag.Attributes.Add("type", "text/javascript");
  StringBuilder PreviewDataScriptCode = new StringBuilder();
  PreviewDataScriptCode.Append("var preview_imgs = [");
  string pathPrefix = @"""";
  string pathSuffix = @""",";
  foreach (string path in this.DocPreviewImages)
  {
      PreviewDataScriptCode.Append(pathPrefix + PreviewUrlBase + Path.GetFileName(path) + pathSuffix);
  }
  // Remove last comma from js code
  PreviewDataScriptCode.Remove(PreviewDataScriptCode.Length-1, 1);
  PreviewDataScriptCode.Append("];");
  PreviewDataScriptTag.InnerText = PreviewDataScriptCode.ToString();
  Page.Header.Controls.Add(PreviewDataScriptTag);
  </code></pre>