runat=server

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
 
S

Scott M.

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
 
G

Guest

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

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
 

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
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top