The specific conditions are as follows:
1. First, the page must refer to the master page to be modified;
2. Create a strongly typed reference to the master page by setting the page directive @mastertype on the page page, specifying a virtual path to generate a strongly typed file such as:
Copy Code code as follows:
<%@ MasterType virtualpath= "~/demo.master"%>
3. Add a public property to the master page, and the set value is assigned to the master page control, for example:
Copy Code code as follows:
public string PageTitle
{
set {
This. Labpagetitle.text = value;
}
}
After the above conditions are met, you can modify the value of the control above the master page on the page page, for example:
Copy Code code as follows:
protected void Page_Load (object sender, EventArgs e)
{
if (! IsPostBack)
{
This. Master.pagetitle = "Page modifies the value of the master page control";
}
}
The Labtitle control value on the master page is set to the page page to modify the master page control's value.