title: How to get element by id in ASP.NET?
body: <p>I tried all the possible solutions to get the value of an element by id, but it did not work. I am using ASP.NET, I have searched for the controls and I know that the server changes the id of the <code>TextBox1</code>, so we use the <code>clientID</code>. But when I write console.log(data1), I get nothing or empty space. </p>
  
  <pre><code>var data1 = document.getElementById('MainContent_TextBox1').textContent;
  var data1 = document.getElementById("&lt;%=MainContent_TextBox1.ClientID %&gt;").value; 
  </code></pre>
  
  <p>This is the ASPX code:</p>
  
  <pre><code>&lt;asp:TextBox ID="TextBox1" runat="server" &gt;&lt;/asp:TextBox&gt;
  </code></pre>
  
  <p>And this the JS code:</p>
  
  <pre><code> var data1 = document.getElementById('MainContent_TextBox1').textContent;
  </code></pre>
  
  <p>In the console, I get this error:</p>
  
  <blockquote>
    <p>Uncaught SyntaxError: Unexpected end of input and its reference in the master file!</p>
  </blockquote>
  
  <p><code>console.log(data1);</code> appears in the console as empty place.</p>
  
  <p>If anyone knows another way or why it is not working, please tell me.</p>