Tuesday, March 31, 2015
ASP.NET MVC List Model Binding
In my previous post I wrote about ASP.NET MVC Basic Model Binding
In this post I will talk about list model binding. Binding list of same type of object is required in many business application either to create bulk records or to update bulk records.
MVC list binding works based on input control naming convention. This can easily be achieved using proper indexing and using For method.
View Model:
Model contains list of Person property which we wish to bind.
Controller:
We have BulkPersonCreate action which will list display the bulk create UI. Also we have POST method for saving list of Person.
View code:
Auto generated naming by view engine:
If you open the view source of your page using browser you can see the naming convention used by view engine.
Output of the app:
When user press Save:
It will submit to BulkPersonCreate POST action.
Here is the debugging output on POST action where action parameter is BulkPersonCreateViewModel with user input data:
Now we can use the binded view model for different business scenario of the app.
Download Source
Sunday, January 18, 2015
ASP.NET MVC Basic Model Binding
ASP.NET MVC Basic Model Binding
View and its underlying model binding is a very important part of MVC. Here, I will show some of the basic steps which helps to understand basic binding concept.
Main terms that is involved in this scenario:
-DTO/Model
-View Model
-Binding
DTO/Model:
Data transfer object (DTO) is one of the main component of OOP programming . Which is used fulfill different application scenario. We often require user input which relates to different DTO's.
MVC has great binding capability which we can use easily.
View Model:
This is a custom model only for view which actually hold the DTO reference and other parts that is required for view.
Controller:
View code:
Output of the app:
When user press Save:
It will submit to Person post action.
Here is the debugging output on Post method where action parameter is PersonViewModel with user input data:
Now we can use the binded view model for different business scenario of the app.
Download Source
View and its underlying model binding is a very important part of MVC. Here, I will show some of the basic steps which helps to understand basic binding concept.
Main terms that is involved in this scenario:
-DTO/Model
-View Model
-Binding
DTO/Model:
Data transfer object (DTO) is one of the main component of OOP programming . Which is used fulfill different application scenario. We often require user input which relates to different DTO's.
MVC has great binding capability which we can use easily.
View Model:
This is a custom model only for view which actually hold the DTO reference and other parts that is required for view.
Controller:
View code:
Output of the app:
When user press Save:
It will submit to Person post action.
Here is the debugging output on Post method where action parameter is PersonViewModel with user input data:
Now we can use the binded view model for different business scenario of the app.
Download Source
Saturday, January 17, 2015
Functional programming - Haskell
Last two week I have been working with Haskell and it is really a great experience. So far I have experience with the imperative programming. I have a chance to work with functional programming with Haskell in my masters program at M.U.M University Iowa, USA . I wanted to share some of my experience.
I have followed most my learning through the book 'Real World Haskell' here is the link :
http://book.realworldhaskell.org/read/
You might follow the above book which is really very helpful to learn Haskell.
I have used Windows environment for this programming.
What you need to do to start?
Download the Haskell platform here: https://www.haskell.org/platform/windows.html
Now we can write some program:
Open GHCi from program files:
This will open Prelude and you can use it just like a calculator:
Is there any easy learning editor?
I have used the Heat editor which is very easy to use and learn
Download here: http://www.cs.kent.ac.uk/projects/heat/
Lets try a factorial problem:
fact n = if n < 2 then 1 else n * fact(n-1)
Really cool it is single line function
Haskell is a real functional programming language. It has really amazing capability you can try that. I am ending my post here :)
I have followed most my learning through the book 'Real World Haskell' here is the link :
http://book.realworldhaskell.org/read/
You might follow the above book which is really very helpful to learn Haskell.
I have used Windows environment for this programming.
What you need to do to start?
Download the Haskell platform here: https://www.haskell.org/platform/windows.html
Now we can write some program:
Open GHCi from program files:
This will open Prelude and you can use it just like a calculator:
Is there any easy learning editor?
I have used the Heat editor which is very easy to use and learn
Download here: http://www.cs.kent.ac.uk/projects/heat/
Lets try a factorial problem:
fact n = if n < 2 then 1 else n * fact(n-1)
Really cool it is single line function
Haskell is a real functional programming language. It has really amazing capability you can try that. I am ending my post here :)
Subscribe to:
Posts (Atom)