Introduced
The master page (MasterPage) is the equivalent of a template page, very simple, nothing to say. Common features based on master pages include the transfer of information between the master page and the content page, the FindControl method in the content page to find the controls in the content page, and so on. In addition, master pages can be nested.
The essential
Add a strong type reference to the master page in the header of the content page
<%--creates a strongly typed reference to the master page and specifies the virtual path to the master page--%>
<%@ MasterType virtualpath= "~/masterpage/masterpage.master"%>
1. The content page passes data to the master page-the master page creates a public method, and the content page invokes the public method through the master. Method
2, master page pass data to content page-master page Create a public event to pass data, and then the content page handles this event
3, content page in the FindControl method to find the control in the content page-with "Master.findcontrol" ("ContentPlaceHolder1"). FindControl ("The control ID you want to find") to find
4, nested master page-say trouble, look at the source bar
Example
Main Motherboard page
Site.master
<%@ Master language= "C #" autoeventwireup= "true" codefile= "Site.master.cs" inherits= "Site"%>