How to modify the value of a master page control on a page page after referencing the master page practical tips

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.