Introduction

About WebMAP: WebForms to Web MVC

WebMAP: WebForms to Web MVC is a tool designed to convert APS .NET (WebForms) apps based on C# to a modern web architecture:
  • Business logic source code is converted to ASP.NET Core.
  • The user interface (UI) rendered as HTML using Angular, JavaScript, and KendoUI.
For VB.Net, contact us for alternatives.

Code Conversions

Here is an example of the very first WebForms application any programmer would do. The program consists of a form and a button that changes the text. The comparison side by side with the converted app shows minimum alterations:
The emphasis of WebMap: WebForms to Web MVC is the transparency for the developer from the original application to the converted one, which is also reflected in the following example code from C# to WebMAP.

Source code DefaultPage.aspx.cs:

1
namespace WebApplication1
2
{
3
public partial class _Default : Page
4
{
5
protected void btn1_Click(object sender, EventArgs e)
6
{
7
this.lbl1.Text = "Hello World";
8
}
9
}
10
}
Copied!

Converted code DefaultPage.aspx.cs:

1
namespace WebApplication1
2
{
3
[Observable]
4
public partial class _Default : Mobilize.Web.UI.Controls.Page
5
{
6
protected void btn1_Click(object sender, EventArgs e)
7
{
8
this.lbl1.Text = "Hello World";
9
}
10
}
11
}
Copied!
The automation of web processes is clear for the user, thanks to internal libraries such as Weaving, that provides functions to interact with the BackEnd/CoreServices. So, the converted code does not add unnecessary complexity and maintains its similarity to the original.
The UI represents a new challenge to convert, and so, we tackle this problem by converting the System.Web.UI into an Angular component divided into three main files:
  1. 1.
    HTML
  2. 2.
    CSS
  3. 3.
    TypeScript
For this same example, the form called DefaultPage.aspx is converted as:

Source code DefaultPage.aspx

1
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>
2
3
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
4
5
<div class="jumbotron">
6
<h3>
7
<asp:Label runat="server" ID="lbl1" Text="My first Sample"></asp:Label>
8
</h3>
9
<asp:Button runat="server" ID="btn1" Text="Click Me" OnClick="btn1_Click"></asp:Button>
10
</div>
11
12
</asp:Content>
Copied!
Every control declared inside the DefaultPage.aspx file will have its corresponding HTML tag as is the case with Button.

Converted code default-page.component.html

1
<div *ngIf='model' class='WebApplication1__Default'>
2
<ng-template #MainContent let-model='model'>
3
<div class="jumbotron">
4
<h3>
5
<wm-label id="lbl1" [model]="model.lbl1" class="lbl1">
6
My first Sample
7
</wm-label>
8
</h3>
9
<wm-button id="btn1" [model]="model.btn1" class="btn1" text="Click Me" [eventsContext]="this" wmClientClick>
10
</wm-button>
11
</div>
12
</ng-template>
13
</div>
Copied!
Now, let's take a look at the .css file that pairs with the default-page.component.html file:

Converted code default-page.component.ts

1
import { Component, ChangeDetectorRef, ElementRef, Output, Renderer2, ViewEncapsulation, ViewChild, TemplateRef} from "@angular/core";
2
import { EventData, dataTransfer} from "@mobilize/base-components";
3
import { PageComponent} from "@mobilize/webforms-components";
4
import { WebMapService} from "@mobilize/angularclient";
5
@Component({
6
selector : "web-application1-default-page",
7
styleUrls : ["./default-page.component.css"],
8
templateUrl : "./default-page.component.html",
9
encapsulation : ViewEncapsulation.None
10
})
11
@dataTransfer(["frmWebApplication1_Default"])
12
export class DefaultPageComponent extends PageComponent {
13
@ViewChild('MainContent')
14
MainContent : TemplateRef <any>;
15
protected webServices : WebMapService;
16
constructor (wmservice : WebMapService,changeDetector : ChangeDetectorRef,render2 : Renderer2,elem : ElementRef) {
17
super(wmservice,changeDetector,render2,elem);
18
}
19
}
Copied!
Now you have covered the basics of what WebMAP: WebForms to Web ASP conversion looks like. Let's proceed with a further explanation of how to run a full conversion process and run the output application by yourself.