MvcExtensions

Represents a series of extensions used to interact with Mvc Web App Razor Views.

Definition

Namespace: Tipi.Tools.UIExtensions.Mvc

Assembly: Tipi.Tools.UIExtensions.Mvc.dll

Package: Tipi.Tools.UIExtensions.Mvc

This class is static and has various methods to render logic directly on your html.

Copied!

                
    /* Usage inside a Razor View, If the third parameter is provided you can specify a class 
       if nothing is provided the default class is "active".*/
    @Html.ActiveClass("Home", "Privacy", "focus")
                
            
ActiveClass example

The ActiveClass method, takes as parameter the Controllers, Actions in which you want to render a provided class name if matched, for example if the Home controller and Index method where provided this method will render the string provided only when you are currently in the Home Controller and Index View.

Copied!

            
    // Renders the string focus only on The Home Controller Privacy View. 
    @Html.ActiveClass("Home", "Privacy", "focus")
                
            
Remarks

The static class Html serves to access its array of static methods that will allow you to interact and render logic within razor pages. This class deppends of the following assembly Microsoft.AspNetCore.Mvc.Rendering in order to work. This assembly is packaged with the release so it doesn't require you to install it.

Methods

This method takes three parameters representing the Controller Name, Action Name and Class Name. The function of this method is to check the provided Controller and Action and if it matches your current page, it renders the Class name provided.