title: Javascript error 'Object doesn't support this property or method' on document.getElementByID?
body: <p>I am attempting to run this JS function when a user clicks on a Panel (in a TableCell). This Panel is an element in a Content Page, which is used with the Master Page which has a Content Place Holder. When I try to click on the panel, the following error is thrown:</p>
  
  <p>Microsoft JScript runtime error: Object doesn't support this property or method</p>
  
  <p>Here is the relevant code for the Master page ASPX:</p>
  
  <pre><code>       &lt;link rel="Stylesheet" href="../includes/styles.css" /&gt;
         &lt;script type="text/javascript" language="javascript"&gt;
             function swapDirections(control) {
                 var main = document.getElementByID('ct100_TableContent_' + control);
                 var long = document.getElementById('ct100_TableContent_' + control + '_long');
                 var short = document.getElementById('ct100_TableContent_' + control + '_short');
  
                 var mainhtml = main.innerHTML;
                 var longhtml = long.innerHTML;
                 var shorthtml = short.innerHTML;
  
                 if (mainhtml.length == shorthtml.length)
                     main.innerHTML = longhtml;
                 else
                     main.innerHTML = shorthtml;
             }
          &lt;/script&gt;
  </code></pre>
  
  <p>Here is the relevant code for the Content page:</p>
  
  <pre><code>            Panel rigDirections = new Panel();
              rigDirections.CssClass = "clip";
              rigDirections.ID = u.Id.ToString() + "_RD";
              string MainDivRD = rigDirections.ClientID;
              Literal rigDir = new Literal();
              string sshort = "";
              if (u.RigDirections.ToLower().Length &gt; (textCutOFF + 4))
              {
                  sshort = Server.HtmlEncode(u.RigDirections.ToLower().Substring(0, textCutOFF).Trim()) + " ...";
                  rigDir.Text = "&lt;a class=RD_RA title=\"Click to Expand\" href=\"javascript: swapDirections('" + MainDivRD + "')\"&gt;" + sshort + "&lt;/a&gt;"; ;
              }
              else
              {
                  sshort = Server.HtmlEncode(u.RigDirections.ToLower().Trim());
                  rigDir.Text = sshort ;
              }
              string slong = Server.HtmlEncode(u.RigDirections.ToLower().Trim());
  
              rigDirections.Controls.Add(rigDir);
              cell.Controls.Add(rigDirections);    
  </code></pre>
  
  <p>And the Content Page ASPX:       </p>
  
  <pre><code>      &lt;asp:Content ID="Content1" ContentPlaceHolderID="TableContent" Runat="Server"&gt;
  
         &lt;asp:Panel ID="pnlTable" Width="950" runat="server"&gt;
  
         &lt;/asp:Panel&gt;
        &lt;/asp:Content&gt;
  </code></pre>
  
  <p>The error is being thrown on the first line of the function. </p>
  
  <p>I have exhausted my internet searching skills, and I have never used JS before, so if anyone has any ideas I would greatly appreciate them.</p>
  
  <p>Thanks!</p>
  
  <p>badPanda</p>