How can we add functionality in the Master page in MVC.
I am using razor view engine and have some views which are using ‘site.cshtml’ as master page.
Now I want all the views to have some search box and button to search, so i have put a search box and button in master page (site.cshtml). now i want to add functionality on buttoon click.
Where should I have to write the code?
Please help.
How can we add functionality in the Master page in MVC. I am using
Share
You should add form to your master page, define search method in one of your controller and if needed search view to show results. Form can be defined like in following example:
Where
Searchis an action inHomecontroller andsearchTermis search string passed as parameter