Is there a way to dynamically add an additional navigation item to my website's menu list when the admin logs in through admin.aspx
? The menu list is created using HTML controls such as <ul>...<li>
, and I would like the new navigation item to be added seamlessly. Alternatively, I could initially include the admin menu item in the list with style { visibility:hidden}
, and then change it to {visibility:visible }
once the login is successful.
Here is an example of my master page code:
<ul id="ul_myLst" runat="server">
<li><a href="Testimonials.aspx">Testimonial</a>
</li>
<li><a href="#fakelink">Contact Us</a>
</li>
<li><a href="#fakelink">About Us</a>
</li>
<li><a href="Registration.aspx">Registartion</a>
</li>
<li><a href="OurFaculty.aspx">Our Faculty</a>
</li>
<li id="abc" runat="server" style="visibility:hidden">
<a href="OurFaculty.aspx">Admin</a>
</li>
</ul>
And here is the Default.aspx
code snippet:
if (f.pass.Equals(txtpass.Value)) {
HtmlGenericControl ul = (HtmlGenericControl)(this.Master.FindControl("abc"));
//ul.Attributes["class"] = "admin-p";
ul.Style.Remove("visibility");
ul.Style["visibility"] = "visible";
Response.Redirect("Index.aspx");
}
The current code works well, but the issue arises when revisiting index.aspx
as the admin menu automatically hides again.