viewmodel

ViewModel with List<BaseClass> and editor templates

南笙酒味 提交于 2019-11-26 00:59:31
问题 I have a view that lists tables being added to a floor plan. Tables derive from TableInputModel to allow for RectangleTableInputModel , CircleTableInputModel , etc The ViewModel has a list of TableInputModel which are all one of the derived types. I have a partial view for each of the derived types and given a List of mixed derived types the framework knows how to render them. However, on submitting the form the type information is lost. I have tried with a custom model binder but because the

How to call functions in a main view model from other view models?

一笑奈何 提交于 2019-11-26 00:44:24
问题 My program is composed of a TreeView and two contentPresenters at ground level. The mainWindow, TreeView , and each contentPresenter all have their own viewModels. I would like to call a function in the mainWindowViewModel from the TreeViewViewModel . I need to do this because the mainWindowViewModel controls what is displayed in the contentPresenters , and I would like to manually update the display. I\'m guessing I would do something like this... TreeViewViewModel : public class

jquery ui datepicker and mvc view model type datetime

十年热恋 提交于 2019-11-26 00:00:30
问题 I am using jquery datepicker on my view model Here is my view: @Html.TextBoxFor(o => o.JobStartDate, new { id = \"dt1\", @class = \"input-block-level\" }) @Html.ValidationMessage(\"JobStartDate\") and my script: $(\"#dt1\").datepicker({ dateFormat: \"dd/mm/yy\" }); Everything works fine if my date is <= 12, if my date is over 12, it will show me an validation error message saying \"The field Start Date must be a date.\" (I am using jquery validation) For example: date 16/12/2014 will give me

ViewModel with List<BaseClass> and editor templates

风流意气都作罢 提交于 2019-11-25 21:50:48
I have a view that lists tables being added to a floor plan. Tables derive from TableInputModel to allow for RectangleTableInputModel , CircleTableInputModel , etc The ViewModel has a list of TableInputModel which are all one of the derived types. I have a partial view for each of the derived types and given a List of mixed derived types the framework knows how to render them. However, on submitting the form the type information is lost. I have tried with a custom model binder but because the type info is lost when it's being submitted, it wont work... Has anyone tried this before? Assuming

What is ViewModel in MVC?

旧街凉风 提交于 2019-11-25 21:32:37
问题 I am new to ASP.NET MVC. I have a problem with understanding the purpose of a ViewModel. What is a ViewModel and why do we need a ViewModel for an ASP.NET MVC Application? If I get a good example about its working and explanation that would be better. 回答1: A view model represents the data that you want to display on your view/page, whether it be used for static text or for input values (like textboxes and dropdown lists) that can be added to the database (or edited). It is something different