Tuesday, 13 May 2014

Click Here to Download CustomRazorHelperClass.zip

It is very easy to write custom razor helper class. After creating custom razor helper class, we can use these classes anywhere in MVC Application.

Here is step by step explanation of creation of razor helper class.

STEP 1 :
First create MVC web application if you do not have MVC Web Application

STEP 2 :
Now Add new "App_Code" folder. In this folder add MVC Razor View page (MVC 4 View Page (Razor)).

To do this, you need to do right click on 'App_Code' folder and click on "Add New Item" menu. It will display dialog box to add new item. After that add 'MVC 4 View Page (Razor)' Page. Give it named like 'CustomRazorHelper.cshtml'.

Now we add one method name 'ToTitleCase', this method makes first character upper case of given statement and make rest of the characters lower case.