Hi, I am working with a third party asp.net application that uses master pages and nested master pages. My needs are to dynamically set the master page files for each page(.aspx). The application by default sets the master page file in the strongly typed @Page directive for each page. I don't want to change the strongly typed directive on each page (over 50 pages) because I am lazy and I want to minimize conflicts with future upgrades.
My solution was to use the base masterpage class and override the OnPreInt event like this:
protected override void OnPreInit(EventArgs e)
{
this.MasterPageFile = "~/MasterPages/MyMaster.master";
}
Everything works perfectly. My question is: Is this a bad idea and why? It just seems too easy to be true.
thanks.