title: Change asp:Label text from C# code behind
body: <p>I've been trying with this for an hour or so; just can't seem to figure out.
  I have an <code>asp:Button</code> on an aspx page, required to complete a couple of functions, one of which is to change the text of an <code>asp:Label</code>. This seems like it should be simple and other online posts indicate that I'm approaching the problem correctly but...</p>
  
  <p>The problem is simple but it's killing me. In an effort to debug/troubleshoot, I've stripped the code right back to very basics:</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
      allValidationMsg.Text = "Original text";
  }
  
  protected void btnRegister_Click(object sender, EventArgs e)
  {
      allValidationMsg.Text = "Text changed";
  }
  </code></pre>
  
  <p>When the button is clicked, nothing happens. I'm sure it's something simple that I'm missing.</p>
  
  <p>Update:</p>
  
  <pre><code>&lt;asp:Label id="allValidationMsg" runat="server" height="22px" ForeColor="Red"&gt;&lt;/asp:Label&gt;
  
  &lt;asp:Button class="navbutton" ID="btnRegister" runat="server" 
                      Text="Register User" OnClick="btnRegister_Click" /&gt;
  </code></pre>