ASP.Net MVC Tute 1 - The Theory
ASP.Net MVC Tute 1 (Starter)
The Theory
The theory is inside the name it self.
M - Model
V - View
C - Controller
When ASP.Net MVC project is created you can see there are 3 folders for Models, Controllers and Views within the project structure (See the figure bellow).
Models folder
We create normal classes.
Ex. Item class.
Use to handle the business logic.
Ex. Create new Item
Use to manage the front end.
Ex. Display Item details.
The Theory
The theory is inside the name it self.
M - Model
V - View
C - Controller
Models folder
We create normal classes.
Ex. Item class.
public class Item { public int Id { get; set; } public string ItemName { get; set; } public double Price { get; set; } }Controllers Folder
Use to handle the business logic.
Ex. Create new Item
public ActionResult Index() { Item item = new Item(); item.Id = 1; item.ItemName = "Lumia 820"; item.Price = 35000; return View(item); }Views Folder
Use to manage the front end.
Ex. Display Item details.
@model ERP.Models.ItemModels.ItemIndex This is the Item page.
Item Details
- ID: @Model.Id
- Name: @Model.ItemName
- Price: @Model.Price
Comments
Post a Comment