Monday 5 June 2017

Registration Page Using MVC

Registration Form & Bind Grid view Using MVC

Step 1st :- Use SQL Server


-- Create Table 


CREATE TABLE UserNewReg
(
Name varchar(50),
Gender varchar(50),
EmailId varchar(50) primary key ,
Password varchar(50),
MobileNo varchar(50)
);

Step 2nd :- Use Visual Basic 2013

--- Create Emplty MVC Project (VijayMVCWebApp)




1--- First Create Model Class



2----Second  Add Validation (UserNewReg.cs)


 public partial class UserNewReg
    {

        [Required(ErrorMessage = "Enter Name.")]
        public string Name { get; set; }

        [Required(ErrorMessage = "Enter Gender.")]
        public string Gender { get; set; }

        [Required(ErrorMessage = "Enter  Email-id.")]
        [EmailAddress(ErrorMessage = "Invalid email address.")]
        public string EmailId { get; set; }

        [Required(ErrorMessage = "Enter Password.")]
        public string Password { get; set; }

        [Required(ErrorMessage = "Enter MobileNumber.")]
        public string MobileNo { get; set; }

    }



3---- Add Controller ("HomeContoller")




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

namespace VijayMVCWebApp.Controllers
{
    public class HomeController : Controller
    {
        // GET: Home
        public ActionResult Index()
        {
            return View();
        }

        //Create Object of DataBase
        DotNetDBEntities db = new DotNetDBEntities();

         //For New Registration
        public ActionResult NewUserAdd()
        {
            return View();
        }

        //Save New USer
        [HttpPost]
        public ActionResult NewUserAdd(UserNewReg emp)
        {
            db.UserNewRegs.Add(emp);
            db.SaveChanges();
            return View();
        }

       //Show User GridView
        public ActionResult UserGridList()
        {
            return View(from user in db.UserNewRegs.Take(10)
                        select user );
            //return View();
        }


    }
}


Note :- Create View as exaple As below Image




eg.:-Code of View(Bind Gridview)  UserGridList.cshtml


@model IEnumerable<VijayMVCWebApp.Models.UserNewReg>

@{
    ViewBag.Title = "UserGridList";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>UserGridList</h2>

<table cellpadding="0" cellspacing="0" class="table">
    <tr>
        <th>Name</th>
        <th>Gender</th>
        <th>EmailId</th>
        <th>Password</th>
        <th>MobileNo</th>
    </tr>
    @foreach (var user in Model)
    {
        <tr>
            <td>@user .Name</td>
            <td>@user .Gender</td>
            <td>@user .EmailId</td>
            <td>@user .Password</td>
            <td>@user .MobileNo</td>
        </tr>
    }
</table>


-----------------------------------------------------------------
OUTPUT
-----------------------------------------------------------------
1:- Registration form with validation


2:-User Bind  Gridview 


18 comments:

  1. A universal message I suppose, not giving up is the formula for success I think. Some things take longer than others to accomplish, so people must understand that they should have their eyes on the goal, and that should keep them motivated to see it out til the end.
    python training in pune | python training institute in chennai | python training in Bangalore

    ReplyDelete
  2. It's interesting that many of the bloggers to helped clarify a few things for me as well as giving.Most of ideas can be nice content.The people to give them a good shake to get your point and across the command
    Java training in Indira nagar | Java training in Rajaji nagar

    Java training in Marathahalli | Java training in Btm layout

    ReplyDelete
  3. In the beginning, I would like to thank you much about this great post. Its very useful and helpful for anyone looking for tips. I like your writing style and I hope you will keep doing this good working.
    aws training in bangalore
    AWS Training
    Aws Certification in Chennai
    best aws training in bangalore
    Best AWS Training in Chennai
    AWS Training in Chennai

    ReplyDelete
  4. I simply wanted to write down a quick word to say thanks to you for those wonderful tips and hints you are showing on this site.

    devops online training

    aws online training

    data science with python online training

    data science online training

    rpa online training

    ReplyDelete
  5. Resources like the one you mentioned here will be very useful to me ! I will post a link to this page on my blog. I am sure my visitors will find that very useful.

    AWS training in chennai | AWS training in annanagar | AWS training in omr | AWS training in porur | AWS training in tambaram | AWS training in velachery

    ReplyDelete
  6. Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had
    not encountered such a step like this.
    Java training in Chennai

    Java training in Bangalore

    Java training in Hyderabad

    Java Training in Coimbatore

    Java Online Training



    ReplyDelete
  7. If you are new user in any site then register after that login. To do it, you can use and access. Registration is possible to use mvc. Future Digital Marketing Options show to make software right. Error can be solved by redirection.

    ReplyDelete

Factorial of a Number

Recently Viewed