Simple web application to register user in ASP.NET MVC


Here is the application for registering a new user in an organization.  This application will show you the use of a master page for showing images on other pages. It will show the validation applied by the user and it will show the record of the registered user in database after registering as well. 

Steps for creating MCN registration in ASP.NET MVC.

Step 1 : First start with opening Visual Studio 2010.

  • Click on File>new

1.gif


Step 2 : After that chose C#>web>ASP.NET MVC web application from installed templates.


2.gif

Step 3 : Now create master page for the site that will be named as site master page.

Steps to create a master page:

  •  Right click on the shared folder (View) >Add >then chose master page
  •  Now design the master page by adding images and other required things which you want to show on all the page
  •  To add image first copy that image to content folder And then navigate the url of image in master page design
     

Step 4 : Now add a controller as required (MCNController)  in the figure shown below:

3.gif

Step 5 : Now code the controller so as to manipulate the function of the page according to the user requirement.
 
Like code will return MCN SOLUTION PVT.LTD on the home page:

using System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.Web.Mvc;

namespace MvcApplication17.Controllers
{
    public
class MCNController : Controller
    {
         //
        // GET: /MCN/
        public ActionResult Index()
       {
              return View("MCN SOLUTION PVT. LTD");
       }
   }
}


4.gif

Step 6 : The next step is to add Model.

  • Now right click on the Model>add.
  • New item model named MCNModel.cs as shown in figure.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace MvcApplication17.Models
{
    [PropertiesMustMatch("Emailid", "re-enter email id", ErrorMessage = "The Emial do not match.")]
     public class REGISTER
    {       
        [Required]
        [DataType(DataType.Int)]|
        [DisplayName("MCN ID")]
        public string ID
        {
            get; set;
        }
        [Required]
        [DataType(DataType.String)]
        [DisplayName("Name")]
        public string Name
        {
           get; set;
        }
        [Required]
        [DataType(DataType.String)]
        [DisplayName("Techology")]
        public string Technology
        {
            get; set;
        }
        [Required]
        [DataType(DataType.String)]
        [DisplayName("Email id")]
        public string Email
        {
            get; set;
        }
        [Required]
        [DataType(DataType.String)]
        [DisplayName("Email id")]
        public string Reenter
        {
            get; set;
        }
    }

Step 7 : Now last step is to add view

  • Right click on controller page >add view as shown in figure (Register)
  • Apply validation to fields required Like

    1. Required Field

    2. Compare to validate etc

5.gif


Step 8 :After adding all the required MVC i.e Model View Controller.
 
Solution Explorer will look like this as image below:

6n.gif

Step 9 : Now last and final step is run by pressing F5.

Note that the image which you are able to see i.e of desktop and welcome to MCN are shown in this view with the help of master page:

7.gif
Step 10 : Now next step is to check record of  all the user in data base as shown:

PC.gif


Similar Articles