Data transfer between masterpage and content pages

Source: Internet
Author: User

MasterPage is a new asp.net in the 2.0. Has the following advantages:

1. Master pages can be used to centralize the common functionality of a page so that updates can be made only in one location.

2. Using master pages makes it easy to create a set of controls and code and apply the results to a set of pages. For example, you can use a control on a master page to create a menu that applies to all pages.

3. By allowing you to control how placeholder controls are rendered, master pages allow you to control the layout of the final page in detail.

4. The master page provides an object model that you can use to customize the master page from individual content pages.

In the actual use of the content page and masterpage between the exchange of data. The following is an introduction to how data is delivered.

1, add the following statement to the content page

<%@ MasterType virtualpath= "~/masterpage.master"%>

The virtualpath value is the path of the Matermage

2, the method of defining public in Materpage

public void SetValue (string s)
{this
.  Label1.Text = s;
Public
String GetValue () {return this
.  Label1.Text;
}  

The SetValue method is used to pass data to masterpage from a content page.

The GetValue method is used to pass data to a content page from MasterPage.

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.