View model is a class, that represents data model used in specific view.

learn more… | top users | synonyms

168
votes
11answers
40k views

ViewModel Best Practices

From this question, it looks like it makes sense to have a controller create a ViewModel that more accurately reflects the model that the view is trying to display, but I'm curious about some of the ...
6
votes
7answers
11k views

MVC - Passing multiple data tables to a view

I currently have the following code in the HomeController of my MVC project: public class HomeController : Controller { public ActionResult Index() { MyDataContext dc = new ...
3
votes
2answers
363 views

Decoration on ViewModel property to use a different name for binding

On MVC3, is there a way to decorate a ViewModel property in order to get the DefaultModelBinder to use a different name for it in the request? For example, suppose you have the following view model: ...
6
votes
2answers
2k views

ViewData and ViewModel in MVC ASP.NET

I'm new to .Net development, and now are following NerdDinner tutorial. Just wondering if any of you would be able to tell me What is the differences between ViewData and ViewModel (all I ...
4
votes
3answers
3k views

ViewModels with asp.net mvc 4 and EntityFramework whats the Point

I'm debating with myself whats the point in creating ViewModel classes in a project which uses Entity Framework? I currently have a project which uses EntityFramework. My solution is structured ...
3
votes
1answer
248 views

Having to repopulate viewmodel when modelstate is invalid due to not sending all data in such as drop down box list

In my project I create a survey, I link this survey to a company and select users to participate. I select survey template, add extra questions and sets information about the survey such as start and ...
2
votes
1answer
158 views

How do I pass an ID from View to the ViewModel as a parameter for GET function?

I'm creating a project using MVC, knockoutJS, Web API, Bootstrap and so forth, the database in use is MSSQL Server 2012. It's all working very well, the controllers have properly created CRUD ...
1
vote
1answer
2k views

Knockout view model posts back to ASP.NET MVC partially - how to post back complete object?

Having these ASP.NET MVC view models: public class User { public string Name { get; set; } public LabeledEmail LabeledEmail { get; set; } } public class LabeledEmail { public ...
4
votes
2answers
284 views

MVC 5 ViewModel not working as it was in MVC 4

I will try to get straight to the point. I had some help building a ViewModel here on StackOverflow. It worked fine in MVC 4 but now that I am converting the application to MVC 5 it is not working. ...
2
votes
2answers
3k views

Show multiple models in a single view using ViewModel in Razor MVC3 (with only Details in view)

My task is to show multiple models into a single view.I've created a ViewModel for my requirement but I'm not meeting my requirement. please have a look into the below code and rectify me where m i ...
2
votes
2answers
302 views

Resuse ViewModel in Asp.net MVC

I have seen lots of blog about MVVM vs MVC and blogs that says thay MVVM is like MVC extension in Windows. I have one design issue, I have made one win application that uses MVVM , now i have to ...
1
vote
1answer
600 views

Is it good to define properties of “Model” type in ViewModel, ASP.net MVC

I've read couple of posts on using ViewModel in ASP.net MVC and realized it is different from "ViewModel" in M-V-VM pattern. ViewModel are used in order to avoid having Model being accessed directly ...
0
votes
2answers
27 views

Form with Two Columns

Hello as the title states I would like to create a form with 2 columns. In the end I want it to look like this jsfiddle I've been playing with. however by looking at the code I don't believe this is ...
0
votes
3answers
764 views

required attribute not working in asp.net mvc

I have a simple "strongly typed view" . @model GoldForGold.Models.LogonModel @{ ViewBag.Title = "Logins"; Layout = "~/Views/Shared/_Layout.cshtml"; } Logins @using (Html.BeginForm()) { ...
0
votes
1answer
780 views

Buddy ViewModel with LINQ Join

SOS! What I am trying to achieve is for the logged in person, to see the users he or she is supporting (buddying). I am now trying to fully embrace ViewModels to coagulate views. I am using ...
0
votes
1answer
605 views

ASP.NET with Knockout variable length list with combobox - how to bind?

With the following ASP.NET models public class User { public string Name { get; set; } public LEmail LEmail { get; set; } } public class LEmail { public IList<CLabel> Labels; ...