What are master pages? | Eklavya Online

What are master pages?

  • Some points about Master Pages,
  • The extension of MasterPage is ‘.master’.
  • MasterPage cannot be directly accessed from the client because it just acts as a template for the other Content Pages.
  • In a MasterPage we can have content either inside ContentPlaceHolder or outside it. Only content inside the
  • ContentPlaceHolder can be customized in the Content Page.
  • We can have multiple masters in one web application.
  • A MasterPage can have another MasterPage as Master to it.
  • The content page content can be placed only inside the content tag.
  • Controls of MasterPage can be programmed in the MasterPage and content page but a content page control will never be programmed in MasterPage.
  • A master page of one web application cannot be used in another web application.
  • The MasterPageFile property of a webform can be set dynamically and it should be done either in or before the Page_PreInit event of the WebForm. Page.MasterPageFile = “MasterPage.master”. The dynamically set Master Page must have the ContentPlaceHolder whose content has been customized in the WebForm.
  • The order in which events are raised: Load (Page) a Load (Master) a LoadComplete (Page) i.e. if we want to overwrite something already done in Load event handler of Master then it should be coded in the LoadComplete event of the page.
  • Page_Load is the name of method for event handler for Load event of Master. (it’s not Master_Load).