GibboK
GibboK

Reputation: 73898

Name mangling for nested Master Pages

I use asp.net 4 and C#.

I have some nested Master Pages; I display in my Content Page a list of Links using a repeater.

This is a sample of code generated by ASP.NET as read in the Source code in the Browser.

As you can see the ID is very lengthy.

My question:

Thanks for your help on this!


<li>
<a id="ContentBody_ContentColumn2_latestArticle_uxRepeaterLatestArticles_uxLink_0" href="Category.aspx?CategoryId=8">AAAAA</a>
</li>

<li>
<a id="ContentBody_ContentColumn2_latestArticle_uxRepeaterLatestArticles_uxLink_1" href="Category.aspx?CategoryId=12">BBBBB</a>
</li>

I would like instead an ID like:

ID="CB_CC_LA_R_0"

ID="CB_CC_LA_R_1"

Useful article: http://www.west-wind.com/weblog/posts/2009/Nov/07/ClientIDMode-in-ASPNET-40 http://msdn.microsoft.com/en-us/library/system.web.ui.control.clientidmode.aspx http://beyondrelational.com/blogs/hima/archive/2010/07/16/all-about-client-id-mode-in-asp-net-4.aspx

Upvotes: 0

Views: 148

Answers (1)

IUnknown
IUnknown

Reputation: 22448

Replace the asp:HyperLink with plain HTML anchor tag and use following markup for it:

<a id='CB_CC_LA_R_<%# Container.ItemIndex %>' href='<%# Eval("IndexPropertyName", "Category.aspx?CategoryId={0}") %>' >
    <%# Eval("TextPopertyName") %>
</a>

Upvotes: 1

Related Questions