Introduction
Step 1: Open Visual Studio 2010.
- Go to file -> New->Projects.
- Create an ASP.NET MVC 2 Empty Web Application.
- Name of "manishRegistration".


Step 2: Add a class in the model folder.
- Right click on the Models folder ->add new items->add class.
- Name of Class is "manish".
- In a class define the properties.


Step 3: Define the business logic in a class.
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- namespace MnaishRegistration.Models
- {
- public class Mnaish
- {
- public string Email_Id { get; set; }
- public string passward { get; set; }
- public string BirthYear { get; set; }
- public string IndianZipCode { get; set; }
- public string Gender { get; set; }
- }
- }
Step 4: Add a controller.
- Right click on the Controllers folder ->add->Controllers.
- Name of Controllers is "manu".
- In a controller, define the request.


Step 5: Write the code in controller.
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using MnaishRegistration.Models;
- namespace MnaishRegistration.Controllers
- {
- public class manuController : Controller
- {
- static List<Mnaish> mm = new List<Mnaish>();
- public ActionResult Index()
- {
- return View(mm);
- }
- public ActionResult Details(Mnaish mm)
- {
- return View(mm);
- }
- public ActionResult Create()
- {
- return View();
- }
- [AcceptVerbs(HttpVerbs.Post)]
- public ActionResult Create(Mnaish monu)
- {
- if (!ModelState.IsValid)
- {
- return View("Create",monu);
- }
- mm.Add(monu);
- return RedirectToAction("Index");
- }
- }
- }
Step 6: Add the 3 view.
- The first view is "index".



Step 7: Write the code in index view.
- <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<IEnumerable<MnaishRegistration.Models.Mnaish>>" %>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" >
- <head runat="server">
- <title>Index</title>
- </head>
- <body bgcolor="#ff9999">
- <h2 style="background-color: #FF8080">manish application</h2>
- <div style="background-color: #CC3399">
- <table>
- <tr>
- <th></th>
- <th>
- </th>
- <th>
- | Passward
- </th>
- <th>
- BitrhYear
- </th>
- <th>
- INdZipCode
- </th>
- <th>
- Gender
- </th>
- </tr>
- <% foreach(var Man in Model) { %>
- <tr>
- <td>
- <%= Html.ActionLink("Details", "Details", Man)%>
- </td>
- <td>
- <%= Html.Encode(Man.Email_Id) %>
- </td>
- <td>
- <%= Html.Encode(Man.passward) %>
- </td>
- <td>
- <%= Html.Encode(Man.BirthYear) %>
- </td>
- <td>
- <%= Html.Encode(Man.IndianZipCode) %>
- </td>
- <td>
- <%= Html.Encode(Man.Gender) %>
- </td>
- </tr>
- <% } %>
- </table>
- <p>
- <%= Html.ActionLink("Login Now", "Create") %>
- </p>
- </div>
- </body>
- </html>
Step 8: Add the second view.
- the second view is" create".



Step 9: Write the code in create view.
- <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<MnaishRegistration.Models.Mnaish>" %>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" >
- <head runat="server">
- <title>Create</title>
- </head>
- <body bgcolor="#ffccff">
- <%= Html.ValidationSummary("Create was unsuccessful. Please correct the errors and try again.") %>
- <% using (Html.BeginForm()) {%>
- <fieldset>
- <legend>Fields</legend>
- <p>
- <label for="Email_Id">Email_Id:</label>
- <%= Html.TextBox("Email_Id")%>
- <%= Html.ValidationMessage("Email_Id", "*")%>
- </p>
- <p>
- <label for="Passward">Passward:</label>
- <%=Html.Password("*") %>
- <%= Html.ValidationMessage("Passward", "*") %>
- </p>
- <p>
- <label for="BirthYear">BirthYear:</label>
- <%= Html.TextBox("BirthYear")%>
- <%= Html.ValidationMessage("BirthYear", "*")%>
- </p>
- <p>
- <label for="IndianZipCode ">IndianZipCode :</label>
- <%= Html.TextBox("IndianZipCode ")%>
- <%= Html.ValidationMessage("IndianZipCode ", "*")%>
- </p>
- <p>
- <label for="Gender ">Gender:</label>
- <%= Html.TextBox("Gender ")%>
- <%= Html.ValidationMessage("Gender ", "*")%>
- </p>
- <p>
- <input type="submit" value="Login" />
- </p>
- </fieldset>
- <% } %>
- <div>
- <%: Html.ActionLink("Back to List", "Index") %>
- </div>
- </body>
- </html>
Step 10: Add the third view.
- the third view is "detail"



Step 11: Write the code in Details view.
- <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<MnaishRegistration.Models.Mnaish>" %>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" >
- <head runat="server">
- <title>Details</title>
- </head>
- <body bgcolor="#ffff99">
- <fieldset>
- <legend>Fields</legend>
- <div class="display-label">Email_Id</div>
- <div class="display-field"><%: Model.Email_Id %></div>
- <div class="display-label">passward</div>
- <div class="display-field"><%: Model.passward %></div>
- <div class="display-label">BirthYear</div>
- <div class="display-field"><%: Model.BirthYear %></div>
- <div class="display-label">IndianZipCode</div>
- <div class="display-field"><%: Model.IndianZipCode %></div>
- <div class="display-label">Gender</div>
- <div class="display-field"><%: Model.Gender %></div>
- </fieldset>
- <p>
- <%: Html.ActionLink("Edit", "Edit", new { /* id=Model.PrimaryKey */ }) %> |
- <%: Html.ActionLink("Back to List", "Index") %>
- </p>
- </body>
- </html>
Step 12: press crtl+f5 run the application.




Arjun SinghPosted Mar 11, 2018, 11:46 AM
Hello, I have a requirement. I have a register tool page in which user will enter the details of some tool and that tool will get updated into our database, however now I want to design its edit view. In which first the user will select that tool and biased on its tool id, I have to show its edit view in which the user can re-enter the tool details.
Ben ReitmaneditedPosted Apr 17, 2013, 11:11 AMEdited Apr 17, 2013, 11:13 AM
Hi Manish!This is nice article written by you. This is very helpful us. During Searching this topic , i have found two more important article link, that also described in a good way with proper example.-------------------- http://www.mindstick.com/Articles/f769698f-fed6-43eb-8e61-d7baaf713819/?Login%20and%20Registration%20Form ---------------------http://www.c-sharpcorner.com/UploadFile/cd3310/create-registration-form-using-Asp-Net-mvc-tools/
nilesh mondePosted Mar 8, 2013, 12:46 AM
there is error for foreach statment GetEnumaration
Yogendra GuptaPosted Oct 11, 2012, 7:38 AM
i want to add ceptcha in mvc2 on login form ..
Yogendra GuptaeditedPosted Oct 11, 2012, 7:38 AMEdited Oct 11, 2012, 7:39 AM
nice..
KarthicKM MPosted Oct 9, 2012, 8:21 AM
Hi sir, I have created the application as you said only but im getting error on this line <%foreach(var Man in (System.Collections.Generic.IEnumerable <Man> Model){ %> i dont know why...
Former memberPosted Jan 4, 2012, 1:19 PM
Hello dear My name is madina.i am interested in having a relationship with you and being your friend.i'm romantic and young Girl,you can send an email to my email address ([email protected]) so that I can send you more details about my self Including my picture.