How to access menu items in the program asp.net

Hi Experts,

I have the following horizontal menu in the master page.

<div id="nav" >
           <ul id="navmenu">
                <li><a href="#">Sales</a><span class="darrow">&#9660;</span>
                    <ul class="sub1">
                         <li><a href="#">Cust. Events</a><span class="rarrow">&#9654;</span>
                             <ul class="sub2">
                                   <li><a href="CreateCustEvent.aspx">Create</a></li>
                                   <li><a href="ViewCustEvent.aspx">View</a></li>
                            </ul>
                         </li>
                    </ul>
                </li>
                <li><a href="sales.aspx">Quoting</a></li>
                <li><a href="#">Parts</a><span class="darrow">&#9660;</span>
                    <ul class="sub1">
                        <li><a href="#">Orders</a></li>
                        <li><a href="#">Receiving</a></li>
                        <li><a href="#">Inventory</a></li>
                    </ul>
                </li>
                <li><a href="#">Maintenance</a><span class="darrow">&#9660;</span>
                    <ul class="sub1">
                            <li><a href="Customer.aspx">Customer</a></li>
                            <li><a href="Vendors.aspx">Vendor</a></li>
                            <li><a href="Parts.aspx">Parts</a></li>
                            <li><a href="Manufacturer.aspx">Manufacturer</a></li>
                            <li><a href="#">Customer Protal</a></li>
                    </ul>
                </li>
               <li><a href="#">Job</a><span class="darrow">&#9660;</span>
                   <ul class="sub1">
                          <li><a href="Createjob.aspx">Create</a></li>
                          <li><a href="ViewJob.aspx">View</a></li>
                          <li><a href="#">Bill Of Materials</a><span class="rarrow">&#9654;</span>
                              <ul class="sub2">
                                   <li><a href="CreateEditBOM.aspx">Create/Edit </a></li>
                                   <li><a href="ViewBOM.aspx">View</a></li>
                              </ul>

                          </li>
                          <li><a href="EmpTimeSheet.aspx">Time Sheet</a></li>
                    </ul>
               </li>
               
           </ul>    
      </div>

I want to make the menu items visible or invisible from the page. Please help me how to do it.
When the user logged in, depending on the role they should be able to see the menu.

Thank you
RadhaKrishnaKiJayaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Lokesh B RDeveloperCommented:
Hi,

1. Add the ID & RUNAT="Server" to all the <a> tags

<li><a href="CreateCustEvent.aspx" id="create" runat="server">Create</a></li>
        <li><a href="ViewCustEvent.aspx" id="view" runat="server">View</a></li>
        <li><a href="Customer.aspx" id="customer" runat="server">Customer</a></li>
        <li><a href="Vendors.aspx" id="vendor" runat="server">Vendor</a></li>

Open in new window


2. In Master Page_Load Check the user is authorized to access the menu items as below.

 
 protected void Page_Load(object sender, EventArgs e)
        {
            string userRole = "Admin";

            if (userRole == "Admin")
            {
                //All menu Items will be Visible

            }

            if (userRole == "Customer")
            {
                //Example the Customer can't create/View other customers
                create.Visible = false;
                view.Visible = false;
            }

}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RadhaKrishnaKiJayaAuthor Commented:
Thank you very much. I will try and let you know.
0
RadhaKrishnaKiJayaAuthor Commented:
Excellent. Thank you very much.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.