Last post Oct 09, 2018 06:18 AM by bjeako
Oct 05, 2018 01:49 PM|bjeako|LINK
I have a default menu. Thats on every page. In the default there is the following:
Only, not every page will not have the same page title. So my question:
How can I create in my controller a function that will do something like if i am on page 2 change the home to contact?
Hopefully this is not too hard.
Oct 06, 2018 11:01 PM|Hisham.NET|LINK
If the header in layout page, simply you can use the ViewData as the following:
on the action
public ActionResult Index()
ViewData["Title"] = "Home";
public ActionResult About()
ViewData["Title"] = "About";
FYI you can use ViewBag too to achieve your requirement
Oct 09, 2018 06:18 AM|bjeako|LINK
By using the code you suggested, I wont get the about or home. Instead. I get the document names.
The result I wanted to be:
Something related to the viewdata. But then being able to make my own custom title work.
In my pages I still had the following piece of code that caused the 'error'
ViewData["Title"] = "Index";
By removing this and adding the code that you suggested in my controller should work!
Thanks for your help & Kind regards!