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