label versus asp:label Question. Thanks.

  • Thread starter Thread starter Shapper
  • Start date Start date
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
 
HTML controls are slightly more efficient.
If performance is your top priority then you should pretty much always use
HTML controls when you don't need the advanced capabilities of the
equivalent web control.
Here's more info:
http://steveorr.net/faq/3in1.aspx#HTMLvsWeb
 
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

Back
Top