I'm trying to access different controls that are located in both of my nested master page templates. Here is a little diagram to keep us all on the same page...
HeaderMaster.master <-- SubPageMaster.master <-- AboutUs.aspx
HeaderMaster.master contains <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> and SubPageMaster.master contains <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>.
My goal is to change the text of each Label from the AboutUs.aspx pageload sub routine.
This code CType(Master.FindControl("Label1"), Label).Text = "blah" seems to work fine when using just one template, but when using it in a nested setup I get this error: System.NullReferenceException: Object reference not set to an instance of an object.
Would someone please tell me how I can access the controls in each template?