ASP.Net controls (e.g. asp:Label) generate messy html ids (e.g. ct100_ct100_Yabba_Dabba_Doo_FinallyTheRealId). Yeah, they're ugly, but someone told me today that they're also:
- unfriendly for SEO
- increase the page size
I half believe 1) and half disbelieve. I know that certain id names (e.g. "header") are keywords that search engines will use to generate meta information, but I'm more skeptical that a span with id="author" really affects SEO. I'm willing to admit that I could be wrong.
On point 2), I'm at least 90% skeptical. Most of page size is not the html characters and I truly wonder if 100 longer ids would even add 1kb to a page size.
I can go with one of two approaches. Which approach would you take?
Approach 1)
<asp:Label id="lblAuthor" runat="server"></asp:Label>
with code behind
protected void Page_Load(object sender, EventArgs e)
{
lblAuthor.Text = "Superman";
or Approach 2)
<span id="author"><%# Eval("Author") %></span>
with code behind
public string Author { get; private set; }
protected void Page_Load(object sender, EventArgs e)
{
Author = "Superman";
On the one hand, 1) doesn't generate the nasty ids. On the other hand, I've always hated untyped strings in asp.net web forms and avoided them when I can. Also, if a page has 30+ elements, I end up with 30 page properties, which makes me feel uneasy. (Side note: a reason to love how the model works in the MVC pattern).
We're working in .Net 3.5.
What are your thoughts?
Thanks.