ARTICLE
Adding Custom Menu in Html Helper class using Extension Method in ASP.Net MVC
This article will show how to add new functionality in HtmlHelper class using Extension method. This will give step by step explanation of, how to create or add MENU functionality n Html helper class and then use that in view of ASP.Net MVC application.
Objective:
This article will show how to add new functionality in HtmlHelper class using Extension method. This will give step by step explanation of, how to create or add MENU functionality n Html helper class and then use that in view of ASP.Net MVC application.
Step 1:
Create an ASP.Net MVC application.
File->New->Project->web->ASP.Net MVC Application

Step 2:
Create Extension method for Html Helper class. -
Add a class to the project. Give a significant name. I am giving name MenuExtension
-
Convert this class to a static class.
-
This class contains two methods.
-
Extension method Menu.
-
Static method GetItems
So, the entire class will look like below listing.
MenuExtension.cs
Step 3:
Create the Controller's ActionIt is a very simple action. It is just creating list of strings and passing that to View. This action is inside controller Home.
Step 4:
Create the View
Step 5:
Adding link at the main page for file uploading
Step 6:
Press F5 to run the application
