After creating a complete master page in Asp.net, you must create a content page. From the perspective of user access, the access path of the content page and the final result page is the same, which indicates that the two are the same file. The result page is a virtual page with no actualCodeThe Code content is the result of merging the master page and content page in the running state.
Before introducing the content page, there are two concepts to emphasize: first, all content on the content page must be included in the content control; second, the content page must be bound to the master page. Although the content page extension is the same as that of a common ASP. NET page, its code structure is quite different. When creating a content page, you must always remember the above two important concepts.
Content Page index. aspx FileSource code
<% @ Page Language = "C #" masterpagefile = "~ /Masterpage. Master "autoeventwireup =" true "codefile =" index. aspx. cs "inherits =" Index "Title =" Example 5-1 "%>
<Asp: Content ID = "content1" contentplaceholderid = "contentplaceholder1" runat = "server">
</ASP: content>
<Asp: Content ID = "content2" contentplaceholderid = "contentplaceholder2" runat = "server">
<P> & nbsp; </P>
<H1> website introduction _ It Channel Network ()
<P> This page is developed based on the new features of the master page from ASP. NET 2.0. There are two main pages: master page and content page. The master page is suffixed with. Master, which encapsulates the shared elements in the website. The content page is actually a common. aspx file, which contains content other than the master page. At runtime, the ASP. net engine combines the two types of page content and sends the result to the client browser. </P>
</ASP: content>
The above rough code is the code structure of the Content Page. It can be seen that the content page is different from the common. aspx file in code. The content page does not contain key web elements such as <HTML>, <body>, and <form>. These elements are all placed on the master page. In addition to the Code header, the content page only contains the content control. The Code header Declaration on the Content Page is similar to that in a common. aspx file. However, the masterpagefile and title attributes are added. The masterpagefile attribute is used to set the path of the master page bound to the content page. The attribute title is used to set the page title value. When you create a content page, because you have specified a bound master page, Visual Studio 2005 automatically sets the masterpagefile attribute value. In addition, two content controls content1 and content2 are set in the source code.
The two controls contain a non-public part of the page. You can set the contentplaceholderid attribute to correspond content1 to contentplaceholder1 on the master page and content2 to contentplaceholder2 on the master page. When the page is running, the content contained in the content control is displayed in the corresponding position on the master page.
Value Transfer between ASP. NET mother edition page and Content Page
Obtain the value of the text box on the master page and assign it to the text box on the Content Page.
This. textbox1.text = (master. findcontrol ("textbox1") as textbox). text;
Returns the value of the text box on the content page to the text box on the master page.
Textbox1.text = (this. contentplaceholder1.findcontrol ("textbox1") as textbox). text;