Tag: MVC

  • ViewData and ViewBag in MVC

    ASP.NET MVC provides us two options ViewData and ViewBag for passing data from controller to view. ViewData and ViewBag are almost similar. Passing data with ViewBag. The ViewBag feature allows us to define arbitrary properties on a dynamic object and access them in a view. The dynamic object is accessed through the Controller.ViewBag property. Let…

  • Creating a Simple Form with Validation Using ASP.NET MVC 4 Empty Template

    There are multiple Validation attributes available in MVC. Validation attributes comes from System.ComponentModel.DataAnnotations. Available validation attributes are- System.ComponentModel.DataAnnotations.CompareAttribute System.ComponentModel.DataAnnotations.CustomValidationAttribute System.ComponentModel.DataAnnotations.DatatypeAttribute System.ComponentModel.DataAnnotations.MaxLengthAttribue System.ComponentModel.DataAnnotations.MinLengthAttribute System.ComponentModel.DataAnnotations.RangeAttribute System.ComponentModel.DataAnnotations.RegularExpressionAttribute System.ComponentModel.DataAnnotations.RequiredAttribute System.ComponentModel.DataAnnotations.StringLengthAttribute System.Web.Security.MembershipPasswordAttribute   Let us create a simple form to request a book using MVC4 basic template. First step is to create the visual studio project. 1.  Open Visual Studio.…