The easiest alternative to creating helpers using the @helper
syntax we mentioned earlier is to create static methods that simply return a string that contains an HTML markup.
In order to accomplish this, we need to complete the following steps:
Create a new folder called
Helpers
inside the root folder of your project.Add a new class to this folder called
Enums.cs
. This file will contain all the enumerators for our project.Add the following code to the
Enums.cs
file:public class Enums { public enum ButtonStyle { Default, Primary, Success, Info, Warning, Danger, Link } public enum ButtonSize { Large, Small, ExtraSmall, Normal } }
Create a new class called
ButtonHelper.cs
in theHelpers
folder.Add a method called
Button
to theButtonHelper
class, and add the following code to it:public static MvcHtmlString Button(string caption, Enums.ButtonStyle...