Confused with concept of View Model

Posted by Laghaterohan under ASP.NET on 5/17/2013 | Points: 10 | Views : 1837 | Status : [Member] | Replies : 4
Hi,
I am learning asp.net mvc. I am confused about using View Model. Could any one please give me some example or demonstrate this concept so that it will clear my confusion. Also, can you suggest me a small tutorial so that I too can practice myself.

Please help.

Best Regards,
Rohan Laghate



Responses

Posted by: Satyapriyanayak on: 5/18/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
http://www.codeproject.com/Articles/188965/ASP-NET-MVC-Overview

If this post helps you mark it as answer
Thanks

Laghaterohan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rabbil on: 5/18/2013 [Member] Starter | Points: 25

Up
0
Down
Sample MVC Tutorial for beginners

http://mvc4beginner.com/Sample-Code/

http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/cs/adding-a-view

http://www.howmvcworks.net/

http://www.dotnet-tricks.com/Tutorial/mvc/QHQT270712-How-to-use-ViewModel-in-mvc3.html

Check the following links for View Model Concepts....
http://www.rachelappel.com/use-viewmodels-to-manage-data-amp-organize-code-in-asp.net-mvc-applications

Hope these would be enough for MVC concept being a Beginner....

Let me know if any clairfication !

"I cannot teach anybody anything. I can only make them think"~ Socrates
Thanks And Regards

Laghaterohan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Annaharris on: 5/18/2013 [Member] Starter | Points: 25

Up
0
Down
Go through the link at the end, and you will get enough information on MVC framework. http://www.howmvcworks.net/

Laghaterohan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Chandrashekarthota on: 5/19/2014 [Member] Starter | Points: 25

Up
0
Down
Rohan,
I will give you a small example to make you understand easily. This doesnt make more sense but this beginner terminology might help you to get basic info on what a viewmodel is.

If you create a website like fb..
1. Home page displays Friends Status
2. Home page displays Your profile pic
3. Home page displays advertisements

There are 3 models here
FriendsStatus.cs
ProfileDetails.cs
Advertisements.cs

Considering MVC - view get data from single model.

We have to show all there models info in home page. How?
Create a view model HomeViewModel = FriendsStatus+ProfileDetails+Advertisements (Combination of view model or combination of required properties in models)
Use this HomeViewModel in Facebook Home View.
This is how we pass multiple models to a view.
That is called creating a model required by a view. In layman term, Model required by a view is a view model.
Its not mandatory that you take all properties in models to create a view model. Just create a view model with what ever properties view demand. Let me know if you need a free online training on working on View models.



Chandra Shekar Thota
Founder/Developer
www.hyderabadtechies.info

Laghaterohan, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response