ASP. NET 2.0 master page (master pages)

Source: Internet
Author: User
ASP. NET 2.0-master pages)

Master pages provides templates for other pages on the website.

Master pages)

Master page enables youProgramCreate consistent appearances and actions for all pages (or page groups) in.

The master page provides templates for other pages with shared layout and functions. The master page defines placeholders that can be overwritten by content pages. The output result is a combination of the master page and the Content Page.

The content page contains the content you want to display.

When a user requests a content page, ASP. NET merges the page to generate an output. The output result merges the layout of the master page and the content of the Content Page.

Master page instance:
<% @ Master %>

<HTML>
<Body>
<H1> Standard Header for all pages

<Asp: contentplaceholderId = "cph1"Runat = "server">
</ASP: contentplaceholder>

</Body>
</Html>

Master page is a common HTML template page designed for other pages.

@ Master commandDefine it as a master page.

This master page contains a placeholder label for the separate content.
<Asp: contentplaceholder>.

Id = "cph1"The property identifies the placeholder and allows many placeholders in the same master page.

The master page is saved"Master1.master".

Note:The master page can also containCodeAllows dynamic content.


Content Page instance:

<% @ Page masterpagefile = "master1.master" %>

<Asp: Content contentplaceholderid = "cph1" runat = "server">

<H2> individual content </H2>
<P> paragrap 1 </P>
<P> paragrap 2 </P>

</ASP: content> 


The content page above is one of the independent content pages.
 

@ Page commandDefine it as a standard content page.

This content page contains a content tag<Asp: content>The tag references the master page (contentplaceholderid = "cph1 ").

The content page is saved"Mypage1.aspx".

When a user requests this page, ASP. NET merges the master page with the content page.

Note:The content text must be in the <asp: content> label. Text outside the tag is not allowed.

Content Page with controls


<% @ Page masterpagefile = "master1.master" %>

<Asp: Content contentplaceholderid = "cph1" runat = "server">

<H2> w3school </H2>
<Form runat = "server">
<Asp: textbox id = "textbox1" runat = "server"/>
<Asp: button id = "button1" runat = "server" text = "button"/>
</Form>

</ASP: content>
The content page above demonstrates how to insert a. Net control into a content page, just like inserting a common page.

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.