Sat 19 Jul 2008
Changing the MasterPageFile Dynamically
Posted by admin under CSharp Commands |
In a project i had been working on i wanted to have a central MasterPageFile that had variable sub MasterPageFile’s. I finally figured out that you have to override the “OnPreInit” Event on the page you wish to modify. Here is an example:-
protected override void OnPreInit(EventArgs e) { if (Web_Security.IsSU()) { this.MasterPageFile = "~/management/SUMasterPage.master"; } else { this.MasterPageFile = "~/management/MemberMasterPage.master"; } base.OnPreInit(e); }
Hope this saves you some time.
No Responses to “ Changing the MasterPageFile Dynamically ”
Comments:
Leave a Reply
You must be logged in to post a comment.