|
Shortening Control IDs in Hyperlinks |
|
I am a big fan of direct navigation on web pages, and to that end, I find myself using a fair amount of asp:hyperlink controls. The problem I ran into was that the ASP.NET generated control id's for these controls was becoming a significant portion of the size of my web pages. So I wrote a helper class, that transforms the auto generated ClientID back into the nice short one you gave the control in the first place (Good for Javascript access and CSS use)
which changes this : <a id="_ctl0__ctl0__ctl0__ctl0__ctl0__ctl0_RightColumnRegion_BlogSideBar1__ctl0_Categorylist1__ctl0_Categories__ctl0_Link" href="http://blog.danbartels.com/APPLE/blogs/sample_weblog/archive/category/1002.aspx">Blogging (2)</a>
into this : <a id="Link" href="http://blog.danbartels.com/APPLE/blogs/sample_weblog/archive/category/1002.aspx">Blogging (2)</a>
To use this, all you have to do is replace your old <asp:hyperlink> tags with your new <DB:href>
Dan
Note: you will need to add a control declaration to your aspx / ascx for this to work.... something like
<%@ Register TagPrefix="DB" Namespace="DanBartels.Controls" Assembly="DanBartels.Controls" %>