Nested Master Page Events not being called

This is the second time I've been caught out by this little feature, so I thought I'd geekzilla it for both reference and to help others.

Scenario

I'm a big fan of MasterPages and Themes as a design principle for web development, and often you need to nest master pages to create complex repeatable layouts.

The Feature

In my child MasterPage I decided to put some code in the Page_Load to populate a related menu, and it wasn't being called....... very strange.. The Top level MasterPages' events were being called, but the child's weren't!

Solution

I'm not sure why it defaults to false but.. you need to change the AutoEventWireup property to true in the Master Directive in the MasterPage.

If this has caught you out, here's the solution.

Author Paul Marshall

A self confessed Microsoft bigot, Paul loves all Microsoft products with a particular fondness for SQL Server. Paul is currently focusing on Web 2.0 patterns and practices and is always looking for better ways of doing things.

I love the .net platform, and I find it to be the most productive toolset I have used to date.

Add Comment

Name
Comment
 

Your comment has been received and will be shown once it passes moderation.