This hit me during a training course last week; we've become used to properties of and ASP.NET page being accessed either directly by the property name or preceded with Page.. When using strongly typed master pages though, the two ways of accessing the Master property aren't the same. For example, assume I have a master page with a public property:
public string TitleText
{
get { return TitleLabel.Text; }
set { TitleLabel.Text = value; }
}
In my content page I have:
<%@ MasterType TypeName="MasterPage" %@gt;
In the content page code, the following works: Master.TitleText = "whatever";
While the following doesn't: Page.Master.TitleText = "whatever";
You don't even get IntelliSense in the latter case and it fails to compile. The reason is the way Page is cast as the strongly typed master page.