Search code examples
asp.netmaster-pages

User control instances are null while using nested master page


I have couple of user controls which are statically referenced in aspx. We are setting some public properties on the user controls in Page_Preinit event. The page also references a master page

This was working fine so far. Had to do a ui redesign and we implemented nested master pages.

Now, all of a sudden, the user controls are showing up as null. If I change the master page to parent one (instead of child -nested), it works fine.

Appreciate any pointers to this issue.

some sample code: here ucAddress is null

protected void Page_PreInit(object sender, EventArgs e) { ucAddress.City = "Dallas"; }

Solution

  • Found the issue. had to initialize child master page before accessing user control.