Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here are two ways to handle that.</p> <ol> <li><p>If you want a really reusable (Application independ solution) you should create a HtmlHelper Method <a href="http://www.asp.net/mvc/tutorials/creating-custom-html-helpers-cs" rel="nofollow">Creating Custom HTML Helpers</a></p></li> <li><p>If you need it just in your Application consider doing something like that.</p> <pre><code>public static class ControllerHelper { /// &lt;summary&gt; /// Checks the current action via RouteData /// &lt;/summary&gt; /// &lt;param name="helper"&gt;The HtmlHelper object to extend&lt;/param&gt; /// &lt;param name="actionName"&gt;The Action&lt;/param&gt; /// &lt;param name="controllerName"&gt;The Controller&lt;/param&gt; /// &lt;returns&gt;Boolean&lt;/returns&gt; public static bool IsCurrentAction(this HtmlHelper helper, string actionName, string controllerName) { string currentControllerName = (string)helper.ViewContext.RouteData.Values["controller"]; string currentActionName = (string)helper.ViewContext.RouteData.Values["action"]; if (currentControllerName.Equals(controllerName, StringComparison.CurrentCultureIgnoreCase) &amp;&amp; currentActionName.Equals(actionName, StringComparison.CurrentCultureIgnoreCase)) return true; return false; } } &lt;ul class="topNav"&gt; &lt;li @if(Html.IsCurrentAction("DashBoard", "DashBoard")) { &lt;text&gt;class="selected"&lt;/text&gt; }&gt;@Html.ActionLink("Dashboard", "Dashboard", new { id = ViewContext.RouteData.GetRequiredString("id") })&lt;/li&gt; &lt;li&gt;@if(Html.IsCurrentAction("Stats", "Stats")) { &lt;text&gt;class="selected"&lt;/text&gt; }&gt;@Html.ActionLink("Stats", "Stats", new { id = ViewContext.RouteData.GetRequiredString("id") })&lt;/li&gt; // .... &lt;/ul&gt; </code></pre></li> </ol> <p><strong>Please tell me if you want to implement the first approach, i will provide more help</strong></p> <p><strong>hope this helps</strong></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload