开发者

Name mangling for nested Master Pages

开发者 https://www.devze.com 2023-03-25 19:13 出处:网络
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.

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开发者_StackOverflow社区 the Source code in the Browser.

As you can see the ID is very lengthy.

My question:

  • How can I have control on the ID generated, so I can chose another format much shorter? Please keep in mind that I cannot get rid of Master Pages for my layout.

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


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>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号