M# Tutorials

Learn to build .NET applications with M#. Our step-by-step tutorials will get you up-to-speed rapidly.
If you already know ASP.NET and C#, you can master M# in a week or two.

Start up

In this lesson we will discuss the page section in M#, which is used to implement page start up code. This is used to implement required actions on page level e.g. redirecting, custom code, roles etc.

M# provides this section under the heading of “Start-up” on any page. Below is a screenshot of “Login” page’s start up section:

This section allows developers to implement start-up procedures. M# adds the code to the “OnInit” event, which is specified in the start-up section. You can use this to perform desired actions on page level e.g. displaying a message, redirecting to other pages based on criteria or any custom code to perform runtime.

We will take an example of “navigate” action and will redirect the user to employee profile page if the employee is already logged in.

The screenshot above demonstrates that the user will be redirected to the employee profile page if the user has Employee role (For more information on “Roles” please read lesson “Roles” in chapter 6). The “Run Server-Side” flag determines that this code will be executed on server side. Below is the generated asp.net code which we specified earlier