Modifying Master Page Properties from the Template File
You may have noted that the master page<title />
element contained the text Untitled Page
. Properties such as this can be modified from within the template file. Let’s set the<title />
element and the litHeader
control to the MCMS Posting Display Name:
1. In Solution Explorer, right-click the
Plant.aspx
file, and click View Code.Add the following
using
statement:using Microsoft.ContentManagement.Publishing;
Enter the following code within the
Page_Load()
method of the template file:string displayName = CmsHttpContext.Current.Posting.DisplayName; Master.Page.Title = displayName; litHeader.Text = displayName;
Note
Code to manipulate master page properties can also be placed in the master page.
Save your work, and from the Build menu, choose Build Web Site.
We can now see that the Display Name is displayed in the Internet Explorer title bar as well as the ASP.NET Literal
control.