title: Question about the "runat" attribute in ASP.NET?
body: <p>I went through <a href="https://stackoverflow.com/questions/304290/asp-net-why-runatserver">this</a> thread but couldn't understand much. I am <em>very</em> new to ASP/HTML/Server-side programming. </p>
  
  <p>I tried running this code on a .aspx file:</p>
  
  <pre><code>&lt;form id="form1" action="Default.aspx"&gt;
      &lt;div&gt;
          &lt;asp:Label ID="lblName"&gt;&lt;/asp:Label&gt;
  
      &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>And I got an error when I tried to use this in the CodeFile:</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
      {
          lblName.Text = "123";
      }
  </code></pre>
  
  <p>"lblName does not exist".</p>
  
  <p>But if I use runat="server" attribute with the label, then this code works.</p>
  
  <p>Also, is there any concept of nesting the runat attribute. e.g, If I specify runat=server for the form above, will all my controls inside the form automatically be configured to run at server? How does this attribute work?</p>
  
  <p>In which case would I be required to specify runat=server for the  and for the  tag? How does the server-side know that the label is inside the form if I don't have a form object at server side? Or am I missing something?</p>