label versus asp:label Question. Thanks.

S

Shapper

Hello,

I am creating a contact form in ASP.NET and I need to access the labels
on Page_Load on my aspx.vb file.

The other elements such as input box and text box don't need to be
accessible.

What are the advantages of using HTML tags such as <label> over the
ASP.NET tags such as <asp:label>?

I am asking cause if it is the same I would always use the asp tags so
if in the future I would need to access them from Page_Load I wouldn't
need to change the tags again.

Thanks,
Miguel
 
S

Scott Mitchell [MVP]

There are actually a few differences. The asp:Label renders as a
<span> tag. Regarding the <label> HTML tag, I assume you mean you will
be using HTML markup and NOT the server-side HTML controls? If so, as
Steve mentioned, these are a bit more performant, but they cannot be
accessed programmatically, as you noted.

Personally I use HTML markup for any content that doesn't need to be
accessed by server-side script, but I know people who like to use
asp:Labels because the VS.NET designer allows you to drag and drop them
and move them around with greater ease than vanilla HTML markup.

Really it's a style of preference. Assuming you don't need to access
the content programmatically, do whichever approach you prefer,
although I'd opt to use the HTML markup myself...
 

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,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top