Click here to Skip to main content
15,903,175 members
Please Sign up or sign in to vote.
1.40/5 (3 votes)
See more:
In every control of ASP.NET we use runat="server"
Do know why we do that?
Posted
Updated 25-Feb-19 1:19am
Comments
R. Giskard Reventlov 6-Oct-10 3:21am    
yes :-)

Runat='Server' Indicates the accessibility of the control at Serverside.

Let Me make you more clear about it.

If you puts runat="server" inside any of the control then you can use that control at the server side.

e.g
XML
<asp:TextBox id="txt" Runat="Server"></asp:TextBox>


string s = txt.Text;


and you can also access Like

TextBox tBox = (TextBox)Page.FindControl("txt");


If you will not provide then it will be not able to find as server doesn't know who is txt.


Please vote and Accept Answer if it Helped.
 
Share this answer
 
You don't need to wait for answers for this type of questions by posting them in forum. A little googling will give you lots of resources within a few second.

http://forums.asp.net/p/1609766/4112578.aspx[^]
 
Share this answer
 
Tag runat="server" indicates that the code contained within the script block will run on the server (and not on the client). On execution, ASP.NET will create server-side objects that contain this code as well as an instance of the Page class to contain the controls defined inside the page as instances of their given type (System.Web.UI.WebControls.Textbox, for example). This server-side object will be invoked on user request and will execute code in response to events.
 
Share this answer
 
Hi,
I advice you to check this link: http://www.w3schools.com/ASPNET/aspnet_controls.asp
Regards
Robert
 
Share this answer
 
runat="server" Indicates the code will be running on the server side .
 
Share this answer
 
Well, just read it as run-at-server - I guess thats self explainatory now what it means in terms of ASP.NET!
 
Share this answer
 
Hi,
I think your newbie.Runat="server" will tells the server to process the control on the server side(not on client side).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900