Quote:
what makes my label accessible in code behind after adding "runat" attribute?
Whenever you do some change in the
ASPX
page, the
designer
file will get updated everytime when the
runat="server"
attribute is added to the control.
Since the designer file is a partial class, the protected members will be accessed in the code behind file.
for example
when you add an asp button to the page
<asp:Button ID="btn" runat="server" />
in the designer file, it will update as
protected global::System.Web.UI.WebControls.Button btn;
and hence the
btn
object is accessible in the code behind, since code behind and designer file are acting as
partial
class.
refer:
c# partial class[
^]
Partial Classes and Methods (C# Programming Guide)[
^]