Sitefinity ASP.NET CMS - Content Management System

Support Forum Thread

Home >  Support >  Forums home > Sitefinity 3.x > General comments > Clearing Div Ids

Reply
Joel, 7/2/2008 4:04:36 PM

What is the best way to edit/change the name of the div ids that are created using the Navigation menus...

For example..

<div class="mainnavright right"
                 <asp:contentplaceholder id="Topmenu" runat="server"></asp:contentplaceholder> 
                 </div>  



Renders:

<div id="ctl00_Topmenu_ctl00_ctl00" class="radmenu RadMenu_CssBlue "
    <!-- 4.4.5 --><script type="text/javascript" src="/Force3/RadControls/Menu/Scripts/4_4_5/RadMenu.js"></script><span id="ctl00_Topmenu_ctl00_ctl00StyleSheetHolder" style="display:none;"></span><ul class="horizontal rootGroup"
 
        <li class="item first"><href="../Home.aspx" id="ctl00_Topmenu_ctl00_ctl00_m0" class="link"><span class="text">Home</span></a></li><li class="item"><href="../federalsolutions.aspx" id="ctl00_Topmenu_ctl00_ctl00_m1" class="link selectedItem"><span class="text">Federal</span></a><div class="slide"
            <ul class="vertical group level1"
                <li class="item first"><href="federalsolutionsoverview.aspx" id="ctl00_Topmenu_ctl00_ctl00_m1_m0" class="link"><span class="text">Overview</span></a></li><li class="item"><href="federalunifiedcommunications.aspx" id="ctl00_Topmenu_ctl00_ctl00_m1_m1" class="link selectedItem"><span class="text">Unified Communications</span></a></li><li class="item"><href="federalmobility.aspx" id="ctl00_Topmenu_ctl00_ctl00_m1_m2" class="link"><span class="text">Mobility</span></a></li><li class="item"><href="federalsecurity.aspx" id="ctl00_Topmenu_ctl00_ctl00_m1_m3" class="link"><span class="text">Security</span></a></li><li class="item"><href="federalsecuritydatacenter.aspx" id="ctl00_Topmenu_ctl00_ctl00_m1_m4" class="link"><span class="text">Data Center</span></a></li><li class="item last"><href="federalsecurityvirtualizationtechnologies.aspx" id="ctl00_Topmenu_ctl00_ctl00_m1_m5" class="link"><span class="text">Virtualization Technologies</span></a></li> 
            </ul> 
 <div>
 

I don't know where the ct100 are coming from, etc.

I would really like this to be a "clean" and raw as possible
and let my theme css and skin handle the styling..






Reply
Joseph, 7/2/2008 4:22:26 PM

The ctl00's are coming from the ASP.NET engine, each copy of the ctlXX is generated by each naming container within the page / control structure.  ASP.NET does this to ensure the uniqueness of the id. In other words It would appear that this control is nested within three other controls.

Joseph Guadagno

http://www.josephguadagno.net

http://www.sevdnug.org




Reply
, 7/3/2008 3:44:31 AM
Hi Joel,

Joseph is right. This is something that cannot be prevented. The ASP.NET control always changes the control ID and name if it is placed inside another control. The ASP.NET control naming structure is using ParentControlID_YourControlID pattern. If the parent control doesn't have an ID, the default id is ctlnnn where nnn is the control index.

There are two approaches to styling you could try:
1. Use CSS class instead of name.
2. Inline styling:
If your CSS is placed in the same ASPX page, you can replace the ID with its server-side syntax. For example, if your ID is divBlock, its server side syntax is <%= divBlock.ClientID %>, so the styling could be defined with:

<style> 
#<%= divBlock.ClientID %> { 
   font-size: large; 
</style> 

I hope the provided information is helpful.

Greetings,
Georgi
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center

Reply
Joel, 7/3/2008 6:56:25 AM

I am confused how I managed to put it

I created a container in the master file and dragged a control into it.
That is it. Why won't this just render a clean div with a definable ID?

It adds it's own ID, classes, etc. and very difficult to sort out.

What am I doing wrong here?

I really don't want to add ctl00_blahblah_ctl00 to my stylesheets...





Reply
, 7/7/2008 11:28:41 AM
Hello Joel,

Please, note that this behavior is applicable to any ASP.NET application, and not only to Sitefinity.

In case you don't want to have confusing IDs in your CSS files, you could apply your styles using Classes.
This way you will apply the style to an item with a defined class attribute. These attributes are not changed by ASP.NET.

I hope that helped. Please, let me know if you need more assistance.

Sincerely yours,
Georgi
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center