ASP. NET learning-Motherboard

Source: Internet
Author: User
The so-called master page is like a base class, which can define some content pages, just like defining interfaces. If other pages reference this master page, A little inherited, so the framework of this new page must be the same as the master page, and if it modifies the content page, it will be the same as the interface that is "overloaded.

Many times, many pages on our website may contain some public parts, such as the header in msdn and the tree on the left. Speaking of this, you may immediately think
IFRAME, huh! However, IFRAME may be difficult to transmit information between pages. I cannot say it for a while. After reading the example below, you may understand
.
Creating a master page is like a normal page, but masterpage is not a webform, for example, test. master. Then add a public part to the master page, for example, adding some tables or other things. Of course, the most important thing is to add one or N content pages. Otherwise, it will be meaningless,
<Asp: contentplaceholder id = "Main" runat = "server"> XXXX </ASP: contentplaceholder>
Note that this ID is very important, because when you rewrite this content page, it also needs to correspond to this ID. At this point, the master page definition is complete. Then the master page is applied.
Create a new webform and reference the master page
<% @ Page masterpagefile = "~ /Test. Master "%>
Of course, there are two methods for global reference and dynamic reference, that is, in Web. confing or in the background Code .
The next step is to specify the content page,
<Asp: Content contentplaceholderid = "Main" runat = "server">
XXXXX
</ASP: content>
If you want to dynamically change the public attributes of the master page, you can directly call master. Attribute = xxx.
Is it much easier than passing parameters between pages of IFRAME?
Of course, my final goal is not to say that IFRAME will be replaced by masterpage. After all, they are not the same thing. It is more convenient to use IFRAME in many places!

Reference address: http://guoxiaocong.cnblogs.com/archive/2005/08/31/226579.html

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.