开发者

How to use menu bars with different patterns?

开发者 https://www.devze.com 2023-02-10 22:25 出处:网络
I\'m using Visual studio 2005, ASP.NET and C#. I want to use menu bars which have an active look to them when their respective target page is the one currently showing.

I'm using Visual studio 2005, ASP.NET and C#.

I want to use menu bars which have an active look to them when their respective target page is the one currently showing.

Imagine a user clicks a menu item, navigation to the target page occurs and the menu item they selected is now differing, in say, color to that of the other items in the menu as a means to indicate this开发者_运维技巧 is the currently active location.

How might one achieve this?


do you want to create a navigation menu, when the user click on some link the target change to different color?

if so, you can do it with html and css only.

or if you like you can create css class. then you can check what page you in and change the cssClass property of object in server side .


The best way to sort this is to add a css class to the button/link which changes the style of the item to highlight it. i.e.

 <ul>
    <li><a id="Url1" href="/Url1" class="selected" runat="server">Item 1</a></li>
    <li><a id="Url2" href="/Url2" runat="server">Item 2</a></li>
 </ul>

I usually try and to this by detecting it from the url so that if the user goes to the page directly the code can handle that too. It can be done either via ServerSide C# or javascript, but I always implement using server-side code as this will still work if the user has JavaScript disabled.

0

精彩评论

暂无评论...
验证码 换一张
取 消