I can't speak for SO but the way this usually works is by generating different HTML for each page along the lines of:
<ul class="tabs>
<li><a href="/tab1">Tab 1</a></li>
<li class="on"><a href="/tab2">Tab 2</a></li>
<li><a href="/tab3">Tab 3</a></li>
</ul>
Where class="on" represents your different styling for your selected tab. Now you don't really want to do this for every page so you can place it in your master page like:
<ul class="tabs>
<li <%= ViewData["CurrentTab"] == "Tab1" ? "class=\"on\"" : "" %>><a href="/tab1">Tab 1</a></li>
<li <%= ViewData["CurrentTab"] == "Tab2" ? "class=\"on\"" : "" %><a href="/tab2">Tab 2</a></li>
<li <%= ViewData["CurrentTab"] == "Tab3" ? "class=\"on\"" : "" %>><a href="/tab3">Tab 3</a></li>
</ul>
Then in each of your controller actions set the value of the tab you want to be selected like:
ViewData["CurrentTab"] = "Tab2";
You could test for the current URL in the Master page but this method offers a little bit more flexibility if multiple URLs should highlight the same tab.
I don't see the need for client side setting but if you needed to use JQuery like James Wiseman said:
$("#Tab1").addClass('on'); // or
$("#Tab1").removeClass('on'); // or
$("#Tab1").toggleClass('on');