Question about the "runat" attribute in ASP.NET? -


I went through the thread but could not understand a lot. I'm new to ASP / HTML / Server-side programming Too many

I tried to run this code on the .aspx file:

  & Lt; Form id = "form1" action = "default.aspx" & gt; & Lt; Div & gt; & Lt; Asp: Label ID = "lbl name" & gt; & Lt; / Asp: Label & gt; & Lt; / Div & gt; & Lt; / Form & gt;  

And when I try to use it in the codefile, I get an error:

  Secure Zero Page_load (Object Sender, EventErgus E) { LblName.Text = "123"; }  

"lblName does not exist".

But if I use the runat = "server" attribute with the label, then this code works.

In addition, is the concept of nesting of the RT attribute, for example, if I specify runat = server for the form given above, should all my controls be automatically on the server Will be configured to run? How does this feature work?

In which case should I specify the raynet = server and for the tag? How does the server side know that the label is in the form if I do not have a form object on the server side? Or am I missing something?

runat = "server" structure know that it is on the server side There will be a control. There are more details in this article:


Comments