17Aug/090
How to access controls in Master Page / Strongly typed Master Page
It is very simple for a page to access the controls in its Master Page.
For example, we can use this way:
((Label)(Master.FindControl(“LblTitle”))).Text = “My Application”;
or
(Master.FindControl(“LblTitle”) as Label).Text = “My Application”;
Can you see that? first, it is not very clean look, second, no intellisence for the LblTitle (the control ID). I don’t like this way of accessing the controls in the Master Page.
I would rather to make the Master Page strongly typed, and create properties or method in the Master Page.
In order to make the Master Page strongly typed, we need to declare the MasterType in the Aspx pages. For example:
<%@ MasterType virtualpath="~/MasterPages/Support.Master" %>