Loading...

What is view and model in MVC?

View: 414    Dowload: 0   Comment: 0   Post by: hanhga   Category: ASP.NET Framework   Fields: none

Model:

MVC stands for model view and controller.

Model contains domain/business/application logic in the form of Object oriented programming pattern (classes). It holds data by using auto-implemented properties.

OR

Model also contains database code such as database connectivity code.

Example: UsersInformation.cs model

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
 
namespace Lesson1.Models
{
    public class UsersInformation
    {
        public int id { get; set; }
        public string Name { get; set; }
        public string Surname { get; set; }
    }
}

View:

Views display/render the model data in the form of G.U.I (Graphical user interface). Views also contains the web controls such as textfields, drop downs, buttons etc. The files in view folder may have cshtml, aspx, html, asp or vbhtml file extensions depends on your language setting environment.

<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<lesson1.models.usersinformation>" %>
<div>
        Date and Time is: <%= ViewData["DateTime"] %>
        Id:   <%= Model.id   %>
        Name: <%= Model.Name %>
        Id:   <%= Model.Surname %>
    </div>
</lesson1.models.usersinformation>


Example: Index.aspx view

 

What is view and model in MVC?

Model contains domain/business/application logic in the form of Object oriented programming pattern (classes). It holds data by using auto-implemented properties.

Posted on 22-08-2016 

Comment:

To comment you must be logged in members.

Files with category

 
File suggestion for you
Loading...
File top downloads
Loading...
Loading...
Codetitle - library source code to share, download the file to the community
Copyright © 2018. All rights reserved. codetitle Develope by Vinagon .Ltd