asp.net 2.0 Master Pages Basics Tutorial

Source: Internet
Author: User

The main page provides templates for other pages on your site.


Main Page
The main page allows you to create consistent look and behavior for all pages (or a set of pages) in your network application.

The main page provides templates for other pages, shared layouts and features. The main page placeholder defines the content that it can overturn on the content page. The output is combined with the main page, the content of the Web page.

The content of the Web page contains content to display.

When the user requests the content page, ASP. NET will combine the page output with the layout of the main page content, the content of the page.

Main Page For example:

<%@ Master%>

  

Above the main page is a normal HTML page design as a template for other pages.

@ Master's instruction definition as main page.

The main page contains a placeholder tag <asp:ContentPlaceHolder> individual content.

The id = "CPH1" attribute determines the reservation location so that many of the placeholders are on the same main page.

This main page is saved with the name "Master1.master"

Note: The main page can also contain code to allow dynamic content.


Content pages for example:

 <%@ Page masterpagefile= "Master1.master"%> <asp:content contentplaceholderid= "CPH1" runat= "Server" > 
The content of the 
 
     

page is more than one page of personal web content. The

@ Page directive is defined as a standard content Web page. The contents of the

Web page contain content tags <asp:Content> and reference main pages (ContentPlaceHolderID = "CPH1").

The content of this Web page is saved with the name "mypage1.aspx"

When the user requests the page, ASP. NET merges the content of the Web page with the main page.

Click to display mypage1.aspx.

  Note: text content must be in <asp:Content> tag. No content is allowed outside of the tag.




Page content control:

 <%@ page masterpagefile= "Master1.master"%> 

&br<asp: Content
contentplaceholderid= "CPH1" runat= "Server"


<form runat= "Server"
<asp:textbox id= "TextBox1" runat= "Server"/>
<asp:button id= "button1" runat= " Server "text=" button "/>
</form>
</asp:content>

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.