yasho yasho -3 years ago 110
ASP.NET (C#) Question

Dynamically add navigations to the masterpage using Javascript

I am getting a list of data, using javascript while loading the home page.
Eg:
[Accounts","Transactions","Amounts","Requests]
And I need to add above list of data to the navigation bar which includes in the master page.

Eg: Navigation Bar
enter image description here

Answer Source

this is very simple. Suppose you have the menu on your master page is UL/LI based menu with an ID "ul"

<ul id="ul"></ul>

then you should write following javascript code on your child page to add menu items dynamically

<script>
        $(document).ready(function () {

            var elements = ["Accounts", "Transactions", "Amounts", "Requests"];

            for(i =0;i< elements.length;i++)
            {
                $("#ul").append("<li>" + elements[i] + "</li>");
            }


        });
    </script>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download