The page code that inherits the motherboard page:
<% @ Page Title = "Home Page" Language = "C #" MasterPageFile = "~ /Site. master "AutoEventWireup =" true"
CodeBehind = "Default. aspx. cs" Inherits = "MasterPageAp. _ Default" %>
General Page code:
<% @ Page Language = "C #" AutoEventWireup = "true" CodeBehind = "WebForm1.aspx. cs" Inherits = "MasterPageAp. WebForm1" %>
The biggest difference is the MasterPageFile attribute.
The master page can be nested in the master page
Access controls and properties on the master page
1. Use the Master. FindControl method to access the control on the Master page
2. reference the @ MasterType command to access the attributes on the master page.
Note the code placement location:
Before the Page_load event of the master page is triggered, the Page_load event of the content page has been triggered.
Controls on the master page are difficult. This example uses the Page_loadComplete event added by ASP. NET and the FindControl party
To obtain the control of the master page. The Page_LoadComplete event is triggered at the end of the web page loading within the lifecycle. Of course
You can also complete this function under the PreRender event of the Label control.