If I am creating a website in ASP.NET, is it possible to programmatically set the title of the page be some predefined value with some extra information tacked on? For example:
Home Page Title = Site Name
Links Title = Site Name: Links
Stuff Title = Site Name: Stuff
Basically, whatever I defined as the main title on the page I’m currently on, I want to tack “: Name” onto the end of the title so it stays consistent across the website. I was thinking of defining it as a ContentPlaceHolder and wrapping some logic around it, but it doesn’t appear to work how I thought it would (AKA, not at all).
While Lerkst’s answer would work for ASP.NET Webforms, I am trying to do this through ASP.NET MVC. As a result, there is no code-behind page for the Site.Master (as there should not be). So, after doing a bit of research, I ran across this post by Guillaume Roy which discusses how to use an ActionFilterAttribute to utilize the Controller in the setting of that data (and the View is “dumb” and only renders it). This allows me to insert data into the view and, thus, accomplishing what I wanted to do.
Hopefully this helps someone else out!