runat=server

  • Thread starter Thread starter Tony Johansson
  • Start date Start date
T

Tony Johansson

Hello!

Is it reasonable at any point having a control without this runat=server
that is either a HTML control or a control prefix with this asp.

If you skip this runat=server this will mean that this control will not be
executed on the webb server.

So one again it seems to me that I should always have this runat=server when
you define a control that
is either a HTML control or a control that is prefix with this asp.

//Tony
 
Tony Johansson said:
Hello!

Is it reasonable at any point having a control without this runat=server
that is either a HTML control or a control prefix with this asp.

If you skip this runat=server this will mean that this control will not be
executed on the webb server.

So one again it seems to me that I should always have this runat=server
when
you define a control that
is either a HTML control or a control that is prefix with this asp.

//Tony

You may be overthinking this Tony.

When a normal HTML control will do, use a normal HTML control (no
runat="server"). If you need a button that initiates some client-side
activity (like a JavaScript function) and that's all it does, then there is
no need to turn it into a server control.

Don't forget that each server control does contribute to the overall
overhead the page will require.

The ability to take a "normal" client-side HTML control and "upgrade" it to
a server control by adding runat="sever" and giving it an id is primarially
there to migrate older non-ASP .NET application to ASP .NET. It's not like
you will be doing a lot of this.

-Scott
 
Hello!

Is it reasonable at any point having a control without this runat=server
that is either a HTML control or a control prefix with this asp.

If you skip this runat=server this will mean that this control will notbe
executed on the webb server.

So one again it seems to me that I should always have this runat=serverwhen
you define a control that
is either a HTML control or a control that is prefix with this asp.

//Tony

For HTML controls you need it only when you want to manipulate the
control at run time. Example:

<a id="link1" runat="server">Hello World</a>

in the code-behind:

link1.Href="http://...";

If you don't want to set the link at run time, use link tag without
the runat=server attribute #

<a href="http://...">Hello World</a>.

ASP.NET controls processed on the server and they require a
runat="server" attribute to work
 
Back
Top