An asp:HyperLink element will of course generate a standard anchor tag. The following, for instance, will generate a class attribute.

<asp:HyperLink CssClass="foo" NavigateUrl="..."></asp:HyperLink>

Generates:

<a class="foo" href="..."></a>

Oddly enough, the standard class attribute appears to do the same in less characters.

<asp:HyperLink class="foo" NavigateUrl="..."></asp:HyperLink>

Generates:

<a class="foo" href="..."></a>

This is all fine enough, but try to set an id and you'll see this isn't always the case (The HyperLink class defines its own ID which takes precedance here). You'll also notice there is no intellisense when using a standard anchor attribute.

So my question is, is this expected behavior (I can't find it documented anywhere)? Is it guaranteed that if I define, say, an onclick attribute or anything that isn't already defined on the HyperLink class that it will transfer over to the generated anchor tag?

Related posts

Recent Viewed