Introduction : I developed a simple application to display person records in ASP.NET using MVC tools. This application for beginners to help them understand what MVC tools is and the benefits of ASP.NET MVC.

ASP.NET MVC gives you a powerful, patterns-based way to build dynamic websites that enables a clean separation of concerns and that gives you full control over markup for enjoyable, agile development. ASP.NET MVC includes many features that enable fast, Test-driven development-friendly development for creating sophisticated applications that use the latest web standards. ASP.NET MVC is a part of the ASP.NET Web application framework. It is one of the two different programming models you can use to create ASP.NET Web applications, the other being ASP.NET Web Forms.

image-mvc.gif

Step 1 : Open Visual Studio 2010.

mvcstart.gif

Step 2 :

mvcmodel.gif

modelclass.gif

Code :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace MvcCustomer.Models
{
public class Person
{
public int id { get; set; }
public string name { get; set; }
public int salary { get; set; }
}
}

Step 3 :

controler.gif

Code :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MvcCustomer.Models;
namespace MvcCustomer.Controllers
{
public class CustomerDiaplayController : Controller
{
//
// GET: /CustomerDiaplay/
public ActionResult Index()
{
Person pr = new Person();
pr.id = 1000;
pr.name = "manish singh";
pr.salary = 20000;
return View(pr);
}
}
}

Step 4 :

view.gif

Code :

<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<MvcCustomer.Models.Person>" %>
<!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>
<div>
Persion id is <% = Model.id %><br />
person name is <% = Model.name %><br />
persone salary is <% = Model.salary %>
</div>
</body
>
</html>

Step 5 :

Output :

output-error.gif

Step 6 :

Output :

ooutput.gif