Introduction
The MVC
(Model-View-Controller) architecture is a way of decomposing an application into
three parts: the model, the view and the controller. It was originally applied
in the graphical user interaction model of input, processing and output. A model
represents an application's data and contains the logic for accessing and
manipulating that data. Any data that is part of the persistent state of the
application should reside in the model objects. The view is responsible for
rendering the state of the model. The presentation semantics are encapsulated
within the view, therefore model data can be adapted for several different kinds
of clients. The controller is responsible for intercepting and translating user
input into actions to be performed by the model. The controller is responsible
for selecting the next view based on user input and the outcome of model
operations.
Example
Simple display the name using
ASP.NET MVC
public
class model
{
public string
name { get; set; }
public int
id { get; set; }
}
model ms =
new model();
public
ActionResult Index11()
{
ViewData["Message"] =
"Welcome to ASP.NET MVC!";
ms.name = "Hello Users";
ms.id = 10000;
return View();
}
<p>
<%=Html.TextBox(Model.name)
%>
</p>
<p>
<%=Html.TextBox(Model.id.ToString())
%>
</p>
Summary
In this
example we simple display the name using ASP.NET MVC tools.