Introduction
- <ul>
- <li id="page1" runat="server" >
- <a href="studentHomePage.aspx"> Dashboard </a>
- </li>
- <li id="page2" runat="server">
- <a href="Mytest.aspx"> My Test</a>
- </li>
- <li id="page3" runat="server">
- <a href="TestReport.aspx">Test Report</a>
- </li>
- <li id="page4" runat="server">
- <a href="Subscription_New.aspx">Subscribe</a>
- </li>
- </ul>
Code Bheind
- page_load {
- String activepage= Request.RawUrl;if(activepage .Contains("studentHomePage.aspx")){page1.Attributes("class") = "active";
- }
- else if(activepageactivepage .Contains("Mytest.aspx")) {
- page2.Attributes("class") = "active";
- }
- else if( activepage.Contains("TestReport.aspx") ) {
- page3.Attributes("class") = "active";
- }
- else if( activepage.Contains("Subscription_New.aspx")) {
- page4.Attributes("class") = "active";
- }}



Asad MalikPosted Aug 27, 2020, 1:45 PM
I have multiple pages..[main page and (1)(2)(3)] and all based on a single master page. only first page is active, how to keep the list hyperlink active while on page 2, 3. please guide.
Noora MJPosted Nov 15, 2018, 5:12 PM
How can i change the color of active page
Charles McClellanPosted Aug 6, 2018, 10:38 AM
How to make this work with asp:menu and asp:menuitem
Hany KhudairPosted Mar 23, 2018, 5:21 PM
Page1.Attributes.Add("class", "active")
Mohammed HablullahPosted Feb 5, 2018, 9:46 PM
How to write this in switch case
Nabeel ArbabPosted May 4, 2016, 6:36 AM
It giving me below error. Non-invocable member 'HtmlControl.Attributes' cannot be used like a method.
Dipayan (DCPL)Posted Feb 19, 2016, 2:42 AM
It giving me below error. Non-invocable member 'HtmlControl.Attributes' cannot be used like a method.