WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

ASP.NET Web Forms - Master Pages


Master pages give formats to different pages on your site.


Master Pages

Master pages enable you to make a steady look and conduct for every one of the pages (or gathering of pages) in your web application.

A ace page gives a format to different pages, with shared design and usefulness. The ace page characterizes placeholders for the substance, which can be abrogated by substance pages. The yield result is a mix of the ace page and the substance page.

The content pages contain the substance you need to display.

When clients ask for the substance page, ASP.NET consolidates the pages to deliver yield that joins the format of the ace page with the substance of the substance page.


Master Page Example

<%@ Master %>

<html>
<body>
<h1>Standard Header From Masterpage</h1>
<asp:ContentPlaceHolder id="CPH1" runat="server">
</asp:ContentPlaceHolder>
</body>
</html>

The ace page above is a typical HTML page planned as a layout for other pages.

The @ Master order characterizes it as an ace page.

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

The id="CPH1" characteristic distinguishes the placeholder, permitting numerous placeholders in a similar ace page.

This ace page was spared with the name "master1.master".

Content Page Example

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

<asp:Content ContentPlaceHolderId="CPH1" runat="server">
  <h2>Individual Content</h2>
  <p>Paragraph 1</p>
  <p>Paragraph 2</p>
</asp:Content>

The content page above is one of the individual substance pages of the web.

The @ Page order characterizes it as a standard substance page.

The content page contains a substance tag <asp:Content> with a reference to the ace page (ContentPlaceHolderId="CPH1").

This content page was spared with the name "mypage1.aspx".

When the client asks for this page, ASP.NET combines the substance page with the ace page.

Click to show mypage1.aspx.


Content Page With Controls

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

<asp:Content ContentPlaceHolderId="CPH1" runat="server">
  <h2>welookups</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 shows how .NET controls can be embedded into the substance page simply like an into a normal page.

Click to show mypage2.aspx.