ASP. NET 2.0 Master Pages basic tutorial

Source: Internet
Author: User

Templates provided on the main webpage. Other webpages are on your website.


Main webpage
The primary web page allows you to create consistent appearances and actions for all web pages (or a group of pages) on your network.

The main webpage provides templates for other webpages to share the layout and functions. The content defined by the placeholder of the main web page, which can be overturned on the content web page. The output result is the content of the main webpage.

The content of the webpage must be displayed.

When a user requests a content webpage, ASP. NET will combine the webpage outputs to deploy the content of the main webpage and the content of the webpage.

The main webpage is as follows:

<%@ Master %>

The top of the main webpage is a normal HTML webpage designed as a template for other webpages.

@ Master's instruction definition is used as the master webpage.

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

The ID = "CPH1" attribute of determines the reserved location, so that many places are placed on the same master page.

The name of the master page is "master1.master"

Note: The main webpage can also contain code that allows dynamic content.


Content webpage example:

 

<%@ Page MasterPageFile="master1.master" %><asp:ContentContentPlaceHolderId="CPH1" runat="server">

The webpage content is more than one personal webpage content.

The @ Page command is defined as a standard content webpage.

The Content of the webpage contains the Content tag <asp: Content> and reference master webpage (ContentPlaceHolderId = "CPH1 ").

The content of this webpage is saved as "mypage1.aspx"

When a user requests a webpage, ASP. NET merges the webpage content with the primary webpage.

Click to display mypage1.aspx.

Note: The text Content must be marked in <asp: Content>. NO content is a flag other than permitted.




Webpage 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>

Related Article

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.