Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Onur 12 posts 32 karma points
    Feb 19, 2013 @ 13:10
    Onur
    0

    navigation menu with asp.net user control

    hi.i wanna do a navigation menu with asp.net usercontrol.how can i use umbraco xml library? somthing like this ?

  • Sahan Rodrigo 25 posts 97 karma points
    Feb 22, 2013 @ 09:56
    Sahan Rodrigo
    0

    Hi Onur,

    You could use "umbraco.presentation.nodeFactory" to get all Nodes and display in a Repeater. I haven't tested this but you can get some idea from below code. 

    protected void Page_Load(object sender, EventArgs e)
    {
                // Get currentpage
                Node topPage = Node.GetCurrent();

     

                // Go to level 1 as top level menu
                while (topPage.Parent != null)
                {
                    topPage = topPage.Parent;
                }
                RepeaterTopLevelMenu.DataSource = topPage.ChildrenAsTable();
                RepeaterTopLevelMenu.DataBind();            
      }           

     

    ASCX

    <asp:Repeater ID="RepeaterTopLevelMenu" runat="server">
        <ItemTemplate>
            <li>
                <a href="<%#umbraco.library.NiceUrl(int.Parse(Eval("Id").ToString())) %>">
                    <%#Eval("NodeName") %>
                </a>
            </li>
        </ItemTemplate>
        <HeaderTemplate>
            <ul id="navi">
        </HeaderTemplate>
        <FooterTemplate>
            </ul>
        </FooterTemplate>
    </asp:Repeater>

     

    Hope this helps,

    Sahan

     

     

Please Sign in or register to post replies

Write your reply to:

Draft