?
Solved

Adding to a child Menu element in code

Posted on 2010-09-11
2
Medium Priority
?
288 Views
Last Modified: 2012-05-10
Good morning,
Ive been struggeling with this for a while, and thought Id try experts-exchange.

Ive put a MenuControl on my page, which I have I have a menu Item called 'Accounts', then a child menu item 'Accounts List', which I need to be able to create a list of accounts, with a href.

So for example, add child menu items such as 'Alliance and Leicester' with a hyperlink of showTransactions.aspx?Account=1, then another one such as 'Barcelys' with a hyperlink of showTransactions.aspx?Account=2.

Ive searched google for 'asp.net MenuItem adding elements in code', but havnt found anything.

Any ideas how I can code these elements in code?

Thank you
0
Comment
Question by:tonelm54
2 Comments
 
LVL 10

Accepted Solution

by:
krunal_shah earned 2000 total points
ID: 33652716
0
 

Author Comment

by:tonelm54
ID: 33652810
Just for anyone else who is looking for this:-



                <asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false" IncludeStyleBlock="false" Orientation="Horizontal" PathSeparator=",">
                    <Items>
                        <asp:MenuItem NavigateUrl="~/Default.aspx" Text="Accounts" Value="Accounts">
                            <asp:MenuItem Text="Accounts" Value="Account List"></asp:MenuItem>
                            <asp:MenuItem Text="Modify Accounts" Value="Modify Accounts"></asp:MenuItem>
                            <asp:MenuItem Text="Reports" Value="Reports"></asp:MenuItem>
                        </asp:MenuItem>
                        <asp:MenuItem NavigateUrl="~/About.aspx" Text="Documents" Value="Documents"/>
                    </Items>
                </asp:Menu>
 
 
    Sub loadNodes()
        Dim item As MenuItem = NavigationMenu.FindItem("Accounts,Account List")
 
        item.ChildItems.Add(newMenuItem("Alliance and Leicter", "viewTransactions.aspx?account=1"))
        item.ChildItems.Add(newMenuItem("Natwest", "viewTransactions.aspx?account=2"))
        item.ChildItems.Add(newMenuItem("Barcleys", "viewTransactions.aspx?account=3"))
        item.ChildItems.Add(newMenuItem("Lloyds", "viewTransactions.aspx?account=4"))
    End Sub
 
    Function newMenuItem(ByVal strText As String, ByVal strNavigate As String) As MenuItem
        Dim newItem As New MenuItem
        newItem.Text = strText
        newItem.NavigateUrl = strNavigate
        newItem.Value = strText
 
        Return newItem
    End Function
 
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month16 days, 14 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question