Pages and Master Pages
Master pages provide templates for other pages with shared layout and functionality. They allow creating a consistent look and behavior for all the pages or group of pages in then application. The master page defines placeholders for the content, which can be overridden by content pages.
The pages contain the content to display.

Events and properties

  • Load event
The load event is triggered at the first time when a page, master page is being loaded, and then the event is triggered after every user interaction.
  • PostLoad command
The PreLoad command is triggered before the first-time load event is called, and every user method interaction.
  • IsPostBack
Gets a value that indicates whether this instance is post-back. When a page is rendered the first time, the value is false and then the value keeps until the page is disposed.
  • IsForm
Gets the value indicating whether this instance is form.
  • Parent
Gets the parent control (master page) where page is contained.

Original example

Html Master Page

1
<%@ Master Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="MainPage.master.cs" Inherits="Test.MainPage" %>
2
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
3
<link href="../../CSS/global.css" rel="stylesheet" />
4
Copied!
The @Master directive defines it as a master page.
The master page contains a placeholder tag <asp:ContentPlaceHolder> for individual content.
The id="Content1" attribute identifies the placeholder, allowing many placeholders in the same master page.

Html Page

1
<%@ Page Title="Test :: TestPage" Language="C#" MasterPageFile="~/Pages/MainPage.master" AutoEventWireup="true" CodeBehind="TestPage.aspx.cs" Inherits="Test.TestPage" %>
2
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
3
</asp:Content>
4
Copied!
The @Page directive defines it as a standard content page.
The content page contains a content tag <asp:Content> with a reference to the master page (ContentPlaceHolderId=" Content1").

Class Master Page

1
namespace Test
2
{
3
public partial class Main : System.Web.UI.MasterPage
4
{
Copied!
Mater Page extends from System.Web.UI.MasterPage.

Class Page

1
namespace Test
2
{
3
public partial class TestPage : System.Web.UI.Page
4
{
5
public MainPage Master { get { return (Test.MainPage)base.Master; } }
6
Copied!
This page extends from System.Web.UI.Page.

Converted Page Sample

Converted code generates four files:

Cs class

1
namespace Test
2
{
3
4
[Observable]
5
public partial class MainPage : Mobilize.Web.UI.MasterPage
6
Copied!
Page cs file extends from Mobilize.Web.UI.Page.
1
namespace Test
2
{
3
4
[Observable]
5
public partial class TestPage : Mobilize.Web.UI.Page
6
{
7
public MainPage Master { get { return (Test.MainPage)base.Master; } }
8
Copied!

Html

1
<wm-usercontrol [model]="model"><div *ngIf="model && model.Visible" class="Test_WebsiteTest_MainPage">
2
<div class="MainPage" [ngStyle]="setMyStyle()" [ngClass]="class" name="MainPage">
3
</div>
4
</div></wm-usercontrol>
5
6
<wm-usercontrol [model]="model"><div *ngIf="model && model.Visible" class="Test_WebsiteTest_TestPage">
7
</div></wm-usercontrol>
8
Copied!
The MasterPage html file contains an additional div element, which doesn’t exist in Page html file.

TypeScript file

The ts file are generated same way for MasterPage and pages.
1
import { Component, ChangeDetectorRef, ElementRef
2
, Output, Renderer2, ViewEncapsulation} from "@angular/core";
3
import { EventData, dataTransfer} from "@mobilize/base-components";
4
import { UserControlComponent, WebComponentsService
5
} from "@mobilize/winforms-components";
6
import { WebMapService} from "@mobilize/angularclient";
7
@Component({
8
selector : "test-testpage",
9
styleUrls : ["./testpage.component.css"],
10
templateUrl : "./testpage.component.html",
11
encapsulation : ViewEncapsulation.None
12
})
13
@dataTransfer(["defTest.TestPage"])
14
export class TestPageComponent extends UserControlComponent {
15
Copied!
Additionally, a css file is generated.

Life cycle

When a Web Forms page runs, the page goes through a life cycle in which it performs a series of processing steps. These include initialization, instantiating controls, restoring, and maintaining state, running event handler code, and rendering.
Diagram Description automatically generated