What is 'Runat" and what does it do?

M

mscurto

I wrote an ASP Web App in Visual Studio and I want the user entered
data to go to a specific server. This runat looks like it is trying to
post to the asp page.

If I remove all instances of it, it looks like it works but it screws
up my page.

What does this command do and can I work around this?
 
R

Rick

Runat sets where the code is to be processed for the item. The only
available option is server. This allows you to process code in the
code-behind for that item.

for instance, <table id="myTable" runat="server">... Will allow you to
access the table named myTable from your code behind. Note: for this to
work properly you may need to manually add the member to your code
behind as well..

protected System.Web.UI.HtmlControls.HtmlTable myTable;

now you'll have access to all the members of the HtmlTable myTable.

it's the same for all the drag and drop server controls as well.

-Rick
 
R

Rick

PS. To send the data to a specific server (database server) that is set
up by the data access logic components and the connection string
(SqlDataAdapter, SqlCommand, etc).

-Rick
 
K

Karl Seguin [MVP]

More technically, runat="server" is something that ASP.NET compiler parses
for in order to turn an html tag into a server side control.

Karl
 
W

Will Asrari

Using the runat and id attributes of a control you can access them
programmatically via code-behind. You can take a native HTML element
such as a table add unique id's to the table rows <TR> with the
runat="server" attribute and show/hide certain rows based on user input.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,266
Messages
2,571,087
Members
48,773
Latest member
Kaybee

Latest Threads

Top