Introduction
This article demonstrates an interesting and very useful concept in ASP.NET MVC.
Question: What is ViewData?
In simple terms "ViewBag is a data holder that enables definition of a key-value pair and that holds the data that can be passed from controller to view".
Step 1: Create a new ASP.NET MVC application


Step 2: Adding New Model


- using System;
- using System.Collections.Generic;
- using System.ComponentModel.DataAnnotations;
- using System.Linq;
- using System.Web;
- namespace ViewDataDemoApp.Models
- {
- public class Addition
- {
- [Required(ErrorMessage = "Please Enter FirstNumber")]
- public int FirstNumber { get; set; }
- [Required(ErrorMessage = "Please Enter SecondNumber")]
- public int SecondNumber
- {
- get;
- set;
- }
- }
- }




Gowtham RajamanickamPosted Mar 11, 2015, 8:33 AM
good....