Developing Login Page In Onsen UI Using Visual Studio 2015

Before reading this article, please go through the article links, mentioned below.

Apache Cordova

Apache Cordova is an open source project, which aims at allowing mobile developers to build the Applications for all the major mobile platforms, using HTML, CSS and JavaScript technologies.

Monaca

Monaca is a software tool and service solution for building and deploying HTML5 mobile hybrid apps. It is built on top of an open source Apache Cordova. Monaca provides a full-suite of resources including Cloud IDE, local development tools, debugger and back-end support.

Monaca's Cloud-based IDE builds HTML5 hybrid mobile apps for iOS, Android, Windows and Chrome apps, using HTML, CSS and JavaScript.

Monaca CLI provides Onsen UI templates, device debugger, remote building and any Service which you might need directly from your terminal.

Onsen UI Framework

Onsen UI is a front-end UI framework to develop cross-platform mobile apps, using Apache Cordova and PhoneGap. It’s fully independent of frameworks and you can easily plug these components into any project, regardless of JavaScript framework.

Onsen UI templates can be used with Visual Studio 2015. All the templates are compatible for Visual Studio Tools for Apache Cordova. It works pretty well with Windows Universal, iOS and Android apps.

Building Login Page with Onsen UI Framework

Let’s see how to start building the login app in Onsen UI Framework using Visual Studio 2015.

Login Page

A login, logging in or logging on is the entering of identifying information into a system by a user in order to access that system (e.g., a computer or a website or an app).

A login generally requires the user to enter two pieces of information; i.e., first the user name and then the password. This information is entered into a login page

A user name is also referred to as an account name. A password differs from a user name, which is intended to be kept secret.


Prerequisites

  • Visual Studio 2015.
  • Visual Studio Tools for Apache Cordova.

Follow the steps, mentioned below, to build a Onsen UI with Login app, using Onsen UI Framework, using Visual Studio 2015.

Step 1

Create an Onsen UI App

Let’s be ready to create a new project. Open Visual Studio 2015 and click File -> New -> Project Option for New Apache Cordova App, using Onsen UI Framework.

Apache

Step 2
 
Give the Project Name

New Project Window will open. Subsequently, you can select an Installed -> Template -> JavaScript -> Manoca ->Onsen UI Blank app.

Type Project name Onsen UI Login Form and click OK button.

Apache

Step 3

Main screen is shown below.

Apache

Step 4

Afterwards, we create the project. Our solution should resemble what is  shown below.

Apache

This table gives the basic idea of how we might use each one.
File Why is it in your project?
Merge Folder It contains the package for Android, ios and Windows apps.
www This file contains the images, library and JS files
config.xml Contains the settings of our app
taco.json Defines which version of the Cordova CLI Visual Studio is used to build the project.

Step 5

Adding the Coding

Go to the index.html in the Solution Bar and add HTML coding. We can add our own HTML coding in between <body> tags.

Apache
  1. Adding the controls

    Go to the index.html in the Solution Bar and add HTML coding

    Explanation

    Coding Explanation
    <ons-page> Create a Page
    <ons-toolbar>Add the Toolbar
    <ons-input> Getting Input from the user
    <ons-button>Create a Submit button

    Coding

    1. <ons-page>  
    2.     <br /><br />  
    3.     <ons-toolbar>  
    4.         <div class="center">Login Page Using Onsen UI </div>  
    5.     </ons-toolbar>  
    6.     <div style="text-align: center; margin-top: 30px;">  
    7.         <p>  
    8.             <ons-input id="username" modifier="underbar" placeholder="Username" float></ons-input>  
    9.         </p>  
    10.         <p>  
    11.             <ons-input id="password" modifier="underbar" type="password" placeholder="Password" float></ons-input>  
    12.         </p>  
    13.         <p style="margin-top: 30px;">  
    14.             <ons-button onclick="login()">Sign in</ons-button>  
    15.         </p>  
    16.     </div>  
    17. </ons-page>  

    Apache

     

  2. Add Validating Coding

    Go to the index.js in the Solution Bar and add JavaScript coding

    Explanation


    Coding Explanation
    login Adding the Login function
    ons.notification.alertDisplaying the Alert Message

    Coding

    1. var login = function() {  
    2.     var username1 = document.getElementById('username').value;  
    3.     var password1 = document.getElementById('password').value;  
    4.     if (username1 === 'admin' && password1 === 'admin') {  
    5.         ons.notification.alert('Congratulations!');  
    6.     } else {  
    7.         ons.notification.alert('Incorrect username or password.');  
    8.     }  
    9. };  
    Apache

     

Step 6
 
Run the Application

Now, we are ready to run our Project. Thus, click Ripple – Nexus (Galaxy) to run the Application. (Apache Ripple is a free mobile simulator).

Apache

Output

Main Screen is given below.

Apache

Output 1

Enter user name and password, as shown below.



Output 2

If the password is right, it is shown below.



Output 3

If the password is wrong, it is shown below.

Apache

Conclusion

I hope you understood how to start the login page in Onsen UI using Visual Studio 2015 and how to run it.

Up Next
    Ebook Download
    View all
    Learn
    View all