C# – Can a user control have a Master Page

asp.netcmaster-pages

I am creating a page that has several user controls (similar to WebParts). Each widget has a common UI section and Content section.

I implemented this using a ParentUserControl that has the common elements and a ChildUserControl that has the content. It works great so far.

I am curious to know if I should have used a single control that has a MasterPage with common UI elements and include this MasterPage across all other children controls? (ofcourse assuming MasterPage can be used within a UC)

Best Answer

Unfortunately MasterPages are designed to work with the Page type. The Page type is designed to use its OnPreInit method to initialize and set up the MasterPage. For this and several other reasons MasterPages cannot be used with UserControls.

What you have set up now sounds pretty good - is there a reason you want to change it?