I created a page with some controls on it. When I put “<% label.Text = “changed”;%>” after the definition of Label, Label’s text value is not rendered after the page is executed. Why?
<div>
<tagprefix:MD ID="CC" runat="server" />
<asp:TextBox runat="server" ID="TextBox1"/>
<asp:Button Text="button" ID="Button" runat="server" onclick="Button_Click" />
<%= "Hello..." %>
<% label.Text = "changed"; %> //working fine
<asp:Label ID="label" Text="text" runat="server" />
<% label.Text = "changed"; %> // do not work
</div>
Why does it display “hello” instead of “world” ?
The answer to that question is also the answer to yours.