---
title: "Creating a simple data entry application using Asp.Net MVC 4"  
description: "In this blog, I’m explaining how to create a simple data entry application using asp.net mvc 4.  Step 1:First open Visual studio 2012 and create an em"  
author: "Sumit Kesarwani"  
published: 2014-02-10  
updated: 2014-09-18  
canonical: https://www.mindstick.com/blog/647/creating-a-simple-data-entry-application-using-asp-dot-net-mvc-4  
category: "asp.net mvc"  
tags: ["asp.net mvc"]  
reading_time: 4 minutes  

---

# Creating a simple data entry application using Asp.Net MVC 4

In this blog, I’m explaining how to create a [simple](https://yourviews.mindstick.com/story/1469/5-simple-ways-to-stay-fit-amp-healthy) data entry [application](https://www.mindstick.com/articles/12824/calculator-application-in-android) using [asp.net mvc](https://www.mindstick.com/forum/155798/what-is-caching-in-asp-dot-net-mvc) 4.\

##### Step 1:

First open [Visual studio](https://www.mindstick.com/articles/12378/visual-studio-for-mac-is-out-of-beta-preview-now-officially-available) 2012 and create an empty asp.net mvc 4 application with razor engine.

##### Step 2:

Add a [controller](https://www.mindstick.com/blog/273/passing-values-from-controller-to-view-in-asp-dot-net-mvc) to the [project](https://www.mindstick.com/articles/105927/how-to-excel-at-managing-multiple-projects) named ”HomeController.cs” with below code:

```
using SimpleDataEntryApp.Models;using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.Mvc;namespace SimpleDataEntryApp.Controllers{    public class HomeController : Controller    {        //        // GET: /Home/        public ActionResult Index()        {            int hour = DateTime.Now.Hour;            ViewBag.Time = hour < 12 ? "Good Morning!" : "Good Afternoon!";            return View();        }    }}
```

##### Step 3:

Now we create a [model class](https://www.mindstick.com/forum/160267/what-is-the-role-of-the-range-data-annotation-and-when-to-use-it-in-a-model-class) and named “Seminar.cs” and add some [properties](https://www.mindstick.com/articles/23331/nootropics-7-different-types-and-their-unique-properties) like below:

```
using System;using System.Collections.Generic;using System.Linq;using System.Web;namespace SimpleDataEntryApp.Models{    public class Seminar    {        public string name { get; set; }        public string email { get; set; }        public string phone { get; set; }        public bool? willAttend { get; set; }    }}
```

##### Step 4:

Now add a view to the project by right clicking in the Index() [ActionResult](https://www.mindstick.com/forum/33961/what-is-the-difference-between-actionresult-and-viewresult) in the “HomeController.cs” file and named it “Index.cshtml”.

```
@{    Layout = null;}<!DOCTYPE html><html><head>    <meta name="viewport" content="width=device-width" />    <title>Index</title></head><body>    <div>       <h3> @ViewBag.Time </h3><br />        We are having a fabulous seminar on Asp.Net MVC in your town.<br />        Register Yourself &nbsp;@Html.ActionLink("here","RegForm")    </div></body></html>
```

I have added an ActionLink in this view to move to the next page when we click on “here”.

##### Step 5:

Now add a ViewResult method in the “HomeController.cs” file like below:

```
[HttpGet]public ViewResult RegForm(){   return View();}
```

And also add a view to this viewresult and named it as ”RegForm” and make it a strongly-typed view like this:

\
![Creating a simple data entry application using Asp.Net MVC 4](https://www.mindstick.com/blogs/1cf27bea-df8f-4f74-ae79-cf433f595256/images/14d410a7-b93d-4aa9-bca8-e23cf164d054.png)

\

And write the below code in the “RegForm.cshtml” file.

```
@model SimpleDataEntryApp.Models.Seminar@{    Layout = null;}<!DOCTYPE html><html><head>    <meta name="viewport" content="width=device-width" />    <title>RegForm</title></head><body>    @using (Html.BeginForm())    {        <p>Name : @Html.TextBoxFor(m => m.name)</p>        <p>Email : @Html.TextBoxFor(m => m.email)</p>        <p>Phone : @Html.TextBoxFor(m => m.phone)</p>        <p>            Will you attend? : @Html.DropDownListFor(m => m.willAttend, new[]{                             new SelectListItem() {Text = "Yes", Value = bool.TrueString},                             new SelectListItem() {Text= "No", Value= bool.FalseString},                         },"Choose an option")        </p>        <input type="submit" value="Submit" />    }</body></html>
```

In this view, I have created a simple form with three textboxes and a dropdownlist and a submit button to submit the values.

##### Step 6:

Now we have created a form, next we need a page to display the values which user has inputted in the form, so add another viewresult to the controller that is “HomeController.cs” like this:

```
[HttpPost]public ViewResult RegForm(Seminar seminarResponse){   return View("Thanks", seminarResponse);}
```

So the whole “HomeController.cs” file look like this:

```
using SimpleDataEntryApp.Models;using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.Mvc;namespace SimpleDataEntryApp.Controllers{    public class HomeController : Controller    {        //        // GET: /Home/        public ActionResult Index()        {            int hour = DateTime.Now.Hour;            ViewBag.Time = hour < 12 ? "Good Morning!" : "Good Afternoon!";            return View();        }        [HttpGet]        public ViewResult RegForm()        {            return View();        }        [HttpPost]        public ViewResult RegForm(Seminar seminarResponse)        {            return View("Thanks", seminarResponse);        }    }}
```

##### Step 7:

Now add a view to the viewresult RegForm(Seminar seminarResponse) by right clicking to it named “Thanks.cshtml” and make it a strongly-typed view like this:

\
![Creating a simple data entry application using Asp.Net MVC 4](https://www.mindstick.com/blogs/1cf27bea-df8f-4f74-ae79-cf433f595256/images/c75339e0-6731-4066-8e19-251509d12074.png)

\

Now write the below code in it:

```
@model SimpleDataEntryApp.Models.Seminar@{    Layout = null;}<!DOCTYPE html><html><head>    <meta name="viewport" content="width=device-width" />    <title>Thanks</title></head><body>    <div>        <h1>Thank you, @Model.name</h1>        @if (Model.willAttend == true)        {            @: We are glad that you are attending the seminar        }        else        {            @:Sorry to hear that you are not coming.        }    </div></body></html>
```

##### Output

Now run the application:

\
![Creating a simple data entry application using Asp.Net MVC 4](https://www.mindstick.com/blogs/1cf27bea-df8f-4f74-ae79-cf433f595256/images/5f09701a-5d4a-44da-9eb5-82ad0af02ee9.png)

\

When you click on “here” will open the “RegForm.cshtml”

\
![Creating a simple data entry application using Asp.Net MVC 4](https://www.mindstick.com/blogs/1cf27bea-df8f-4f74-ae79-cf433f595256/images/94a3b43e-5c8d-4e6f-bfca-75333b6d0d0f.png)

\

![Creating a simple data entry application using Asp.Net MVC 4](https://www.mindstick.com/blogs/1cf27bea-df8f-4f74-ae79-cf433f595256/images/415b816d-95a7-4f84-b823-0294df94ddd0.png)

\

Fill the form with appropriate values and click on submit button:

\
![Creating a simple data entry application using Asp.Net MVC 4](https://www.mindstick.com/blogs/1cf27bea-df8f-4f74-ae79-cf433f595256/images/2da1b12f-f5fc-4c14-b606-782684913186.png)

---

Original Source: https://www.mindstick.com/blog/647/creating-a-simple-data-entry-application-using-asp-dot-net-mvc-4

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
