What does a template page do?
The use of template pages can easily and quickly create a unified style of ASP.net Web site, and easy to manage and maintain, improve efficiency.
The template page defines the appearance and criteria that are required for a Web page, and builds on the master to create individual content pages that contain display content. When a user requests a content page, the content pages are merged with the master page, so that the layout of the template page and the layout of the content page can be grouped together for output.
Template pages are typically used to:
1, by modifying the template page to deal with the general functions of the Web page.
2, you can easily create a set of controls and code, and apply to a group of web pages.
3. By allowing control over the rendering of placeholder controls, template pages can control the layout of the final page in detail.
Template pages and plain pages
We create a template page in VS, where we can see something different from the general content:
The @Master replaces the @page, and contains several replaceable placeholder ContentPlaceHolder.
To associate a normal page with a master page:
Normal page properties, MasterPageFile, will give you the hint to choose the master page you are using, or choose to use the master page when you create a new page, or you can apply a master page to the normal page.
DEMO:
Template page Code:
<%@ Master language= "C #" autoeventwireup= "true" codefile= "MasterPage2.master.cs" inherits= "Template page _masterpage2"%> <! DOCTYPE htmlpublic "-//w3c//dtd XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
Content page Code:
<%@ page title= "language=" C # masterpagefile= ~/template page/masterpage2.master "autoeventwireup=" true "codefile=" ContentPage.aspx.cs "inherits=" Contentpage "%>
<asp:contentidasp:contentid=" Content1 " Contentplaceholderid= "Head" runat= "Server" >
</asp:Content>
<asp:contentidasp:contentid= " Content2 "contentplaceholderid=" ContentPlaceHolder1 runat= "Server" >
<p>
Add content page </p>
Show:
About master Pages and topics:
Same as the master and theme in ppt. That is true:
The use of templates can be based on its own content can be added, the equivalent of a good frame, style and so on. The master is equivalent to a component that needs to be framed, styled, and so on. The master is an abstraction of the same unchanging part from many similar structure pages and can be used in more pages to save time.
This simple example is not to help you better understand the use of the master page, I hope you will continue to focus on the small share of the article.