Span vs Label

T

tshad

I am trying to find out why it would be better to use an asp:label vs a span
( <Span ID="FileName" RunAt="Server"/>).

I know that labels get sent as spans, so why not just use the span object?

Just curious.

Thanks,

Tom
 
N

Norman Yuan

At client (browser) end, both are porbably the same. But in the regard of
APS.NET developing, Label is a server-side web control and <SPAN /> is not,
even though it is mared as RunAt="Server". Label inherits all
properties/methods/events from System.Web.UI.Control, while <SPAN /> does
not. Functionally, the difference of using them in your ASP.NET page may be
small, the concept is different, even though they may do the almost same
thing.

Actually, you can almost use Html controls only for your ASP.NET page (after
all, all web controls will be rendered to Html thing when sending to
browser), then you will lose all advantages to work with ASP.NET.
 
C

Craig Deelsnyder

I am trying to find out why it would be better to use an asp:label vs a
span
( <Span ID="FileName" RunAt="Server"/>).

I know that labels get sent as spans, so why not just use the span
object?

Just curious.

Thanks,

Tom

Mainly because the 'full-fledged' controls like Label provide a richer set
of APIs (events, properties, etc.), than their HTML server control
counterparts. Look through the members of each type in MSDN help; you'll
see the difference.

If you don't need the 'extra' stuff, though, doesn't really matter either
way.
 
M

Marina

Actually, the tag would have to be something like this:

<asp:Span ID="FileName" RunAt-"Server" />

In any case, the reason is that people are used to the term 'Label' meaning
a read only fields on their form. To many people 'Span' does not mean
anything, esp. those that are coming from windows or just starting out. But
everyone can understand what a 'Label' is.

Additionally, maybe now the Label is turned into a span. Who knows if it
will always be that way. Maybe some day the 'asp:Label' tag will spit out a
DIV. Or some other new tag. The point is, there is an abstraction between
the actual object, and the details of the implementation of that object.
 
B

Bruce Barker

there is also a html label (<label>) which should always be used to label
input controls. its required for section 508 (of the Rehabilitation Act)
compliance.

-- bruce (sqlwork.com)
 
J

joey.powell

That abstraction layer also provides for the asp.net engine to be able
to render different tags, depending on what browsers are making
requests.

For example IE might introduce some new functionality that Firefox or
Opera doesn't support. The asp.net engine could analyize the request
and emit the new tags for IE and the older span tags for the others.

JP>
 

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

Forum statistics

Threads
473,755
Messages
2,569,539
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top