title: JavaScript runtime error: Unable to get property 'innerHTML' of undefined or null reference in asp.net
body: <p>I have a textbox in which user will write some text.</p>
  
  <p>Now If he wants to print that text he should click on print button.
  The design of Print button is as follows:</p>
  
  <pre><code>&lt;asp:Button ID="btnPrint" runat="server" Text="Print" Enabled="False" OnClientClick = "CallPrint('txtReadFiles')" /&gt;
  </code></pre>
  
  <p>Now in the head part of aspx page the function CallPrint is declared as follows : </p>
  
  <pre><code>&lt;script type="text/javascript" language="javascript"&gt;
          function CallPrint(strid)
          {
              var prtContent = document.getElementById(strid);
              **var docwrite=prtContent.innerHTML;**
              var WinPrint = window.open('','','left=0,top=0,toolbar=0,status=0');
              WinPrint.document.open();
              WinPrint.document.write(docwrite);
              WinPrint.document.close();
              WinPrint.focus();
              WinPrint.print();
              WinPrint.close();
          }
      &lt;/script&gt;
  </code></pre>
  
  <p>But when I click on print button I get an error on line marked with **</p>
  
  <p>JavaScript runtime error: Unable to get property 'innerHTML' of undefined or null reference</p>
  
  <p>What is the problem here?</p>