asp.net 2.0 (C #) (1)

Source: Internet
Author: User

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"%>

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.