How to set your master page by the nested page

The PreInit Page event n the nested page can be used for setting some Master page parameters.

protected void Page_PreInit(object sender, EventArgs e)
(this.Master as MasterType).Property = value;

Then the Master page will be loaded and rendered using these settings.
Master is the reference to the Master page. MasterType is the type of master page used.
Property is the public variable which must be set before loading page.

Using Page_PreInit the Master page can be set dynamically.

No comments:

Post a Comment