The Pre_Init event is a key event to examine if we want to change the master page file programmatically.
public class BasePage : Page
this.PreInit += new EventHandler(BasePage_PreInit);
void BasePage_PreInit(object sender, EventArgs e)
MasterPageFile = "~/Master1.master";
We get error "The 'MasterPageFile' property can only be set in or before the 'Page_PreInit' event." If we try to change master page in any other event than Pre_Init.