I’ve been using PHP for 7 years or so now, but as of today I’ve been thrust into using .NET for a project. Just for an insite:
This project features:
.NET4
Viewstate = false
Now my issue is this. The main layout is covered by the master page which seems quiet obvious how it works. It also includes nav menu options such as:
<div id="menu">
<ul>
<li><a href="default.aspx" title="Home" >Home</a></li>
<li><a href="products.aspx" title="Products">Products</a></li>
<li><a href="prices.aspx" title="Size & Price">Size & Price</a></li>
<li><a href="formats.aspx" title="File Formats">File Formats</a></li>
</ul>
</div>
Now what I would like to do would be to add a CSS class attribute depending on what page I’m on so if I was on the products page I’d get the following source:
<div id="menu">
<ul>
<li><a href="default.aspx" title="Home" >Home</a></li>
<li><a href="products.aspx" class="active" title="Products">Products</a></li>
<li><a href="prices.aspx" title="Size & Price">Size & Price</a></li>
<li><a href="formats.aspx" title="File Formats">File Formats</a></li>
</ul>
</div>
Any help would be greatly appreciated!
Cheers 🙂
Lots of ways to do this, one way is to add a script to the “slave” page that sets the class of the appropriate tag.
Then in products.aspx you can do: