Click here to Skip to main content
14,883,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is my code

ASP.NET
<asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false" IncludeStyleBlock="false" Orientation="Horizontal">
                    <Items>
                        <asp:MenuItem NavigateUrl="~/Default.aspx" Text="Home"/>
                        <asp:MenuItem NavigateUrl="~/About.aspx"   Text="About"/>
                        <asp:MenuItem NavigateUrl="~/StudentEnquiry.aspx" Text="Enquiry Form"/>
                        <asp:MenuItem NavigateUrl="~/Reports.aspx" Text="Reports" />
                    </Items>
                </asp:Menu>



I just want to disable the Reports.aspx menu in NavigationMenu when he is a Normal User, it will show when he is a admin user.


This is my code, when i redirect from this page to StudentEnquiry page the Reports page should disable. could anyone tell me...

C#
protected void Page_Load(object sender, EventArgs e)
       {
           string SAuth = Request.QueryString.Get(0);
           if (SAuth == "True")
           {
             Label1.Text = Convert.ToString(Session["EmpId"]);
             string type = Convert.ToString(Session["User_Type"]);

             //  Label1.Text = "Authenticated";
             if (type == "Adm")
             {
                 // I think i need to write some code here
                 Response.Redirect("StudentEnquiry.aspx?a=" + Label1.Text + "");
             }

           }
           else
           {
               Label1.Text = "Not Authenticated";
           }
       }
Posted
Updated 8-Apr-14 1:23am
v2

oh!! Just check this page:

A clear cut details of what exectly you want

Implement Role based security, Page access and Show/Hide Menu items based on Role in
   
v2
XML
<% if (IsAdmin ==true ){ %>
                   <asp:MenuItem NavigateUrl="~/Default.aspx" Text="Home"/>
                      <asp:MenuItem NavigateUrl="~/About.aspx"   Text="About"/>
                      <asp:MenuItem NavigateUrl="~/StudentEnquiry.aspx" Text="Enquiry Form"/>
                      <asp:MenuItem NavigateUrl="~/Reports.aspx" Text="Reports" />
          <%} %>

            <% else{ %>

                      <asp:MenuItem NavigateUrl="~/Reports.aspx" Text="Reports" />
          <%} %>


IsAdmin will be protected bool in Code behind
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900