+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Clearing Div Ids

Clearing Div Ids

5 posts, 0 answered
  1. Joel
    Joel avatar
    28 posts
    Registered:
    18 Jun 2008
    02 Jul 2008
    Link to this post

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





  2. Joe
    Joe avatar
    64 posts
    Registered:
    05 Jul 2012
    02 Jul 2008
    Link to this post

    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



  3. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    03 Jul 2008
    Link to this post
    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
  4. Joel
    Joel avatar
    28 posts
    Registered:
    18 Jun 2008
    03 Jul 2008
    Link to this post

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




  5. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    07 Jul 2008
    Link to this post
    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
Register for webinar
5 posts, 0 answered