viewmodel

Asp.net MVC Razor more than one form on a page

瘦欲@ 提交于 2019-12-12 18:16:56
问题 Yo I have a registration page on my site - at the top of the page is a login form for existing users. In the main area there is the registration form. The login are is a partial view with @model ViewModels.LoginViewModel The registration are is also a partial with @model ViewModels.RegViewModel The main page which houses these partials is a view with @model ViewModels.RegPageViewModel This viewmodel looks like: public class RegViewModel { public RegisterVm RegisterVm { get; set; } public

Creating View Models consisting of objects of other models in MVC3

随声附和 提交于 2019-12-12 16:42:24
问题 I have a model and an enumerable of that model that I am putting together into a view model in asp.net mvc3 like so. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.ComponentModel.DataAnnotations; namespace FuelPortal.Models.DBModels { public class UserDBModel { public int userId { get; set; } [Required, Display(Name = "User Name")] public string userName { get; set; } [Required, Display(Name = "Password")] public string password { get; set;

Remove from Observable collection in ViewModel does not update View, but Updates of Existing Items does update View

China☆狼群 提交于 2019-12-12 12:15:45
问题 I'm sure this will be a slam dunk for someone... fingers crossed My ListView ItemsSource is bound to a Property on my ViewModel named TileItems. Populating the list view updates perfectly. In the ViewModel, where you see "existingTileItem.Transaction = e.Transaction" . . . The individual listview item updates perfectly. In the ViewModel, where you see "Me.TileItems.Remove(existingTileItem)" ... The item is not removed from the View. It does successfully remove from the Me.TileItems collection

Possible bug in Html.DropDownList, selected values not reflecting?

五迷三道 提交于 2019-12-12 09:28:30
问题 I know this has been asked a few times before, but the existing solutions look like hacks rather than a proper pattern. I have a simple drop down list. I am trying to populate it with data and have a item pre selected. I am succeeding at the 'populate it with data part' but failing to get my preferred item pre-selected. I am using ASP.NET MVC 3 RC2. The important code bits: { // Bunch of code CategoryOptions = new SelectList(categories, "Id", "Slug", article.Category.Id); } Now... the

Updating a reference to a command of a nested ViewModel?

痴心易碎 提交于 2019-12-12 09:13:09
问题 I know I'm probably missing something simple and obvious, but at the moment it eludes me. I'm attempting to use the MVVM pattern. How do you update a reference to a command in a viewmodel that is linked to a child viewmodel? I've got a view (MainView) bound to a viewmodel (MainViewModel). On MainView, I've got an instance of another view (SummaryView) bound to a viewmodel (SummaryViewModel). SummaryViewModel contains a collection of a third viewmodel (SummaryFilterViewModel). On SummaryView,

Architecture components ViewModel vs. savedInstanceState bundle

只谈情不闲聊 提交于 2019-12-12 08:29:13
问题 Trying to understand what is the difference with using the ViewModel to keep some of the state of the activity or fragment, and saving them with the savedInstanceState bundle. Got a impression that the ViewModel instance is kept alive when the activity/fragment is destroyed by os in the case like configuration change so that when os recreate the activity/fragment could get the data from the ViewModel instance which is still valid. Does it apply to minimize the app and re-open it? Did some

What is the best way to build view model?

拟墨画扇 提交于 2019-12-12 08:05:54
问题 I'm using asp.net mvc with entity framework and starting to learn DDD. I'm working on project that contains surveys. Here's my domain model: public class Survey { public int? SurveyID { get; set; } public string Name { get; set; } public decimal MinAcceptanceScore { get; set; } public int UserFailsCount { get; set; } public IEnumerable<SurveyQuestion> Questions { get; set; } public IEnumerable<Prize> Prizes { get; set; } public IEnumerable<SurveyAttempt> UserAttempts { get; set; } } I need

MVC ViewModel - Object Reference Not Set to Instance of an Object

只愿长相守 提交于 2019-12-12 06:29:54
问题 I receive an "Object reference not set to instance of an object" error while trying to convert a DataTable into a viewmodel containing rows and columns. ViewModel public class ViewModel { public List<ColumnViewModel> Columns { get; set; } public List<RowViewModel> Rows { get; set; } } public class ColumnViewModel { public string Name { get; set; } } public class RowViewModel { public List<CellValueViewModel> Values { get; set; } } public class CellValueViewModel { public string Value { get;

SaveState in MvvmCross is not being called in an iOS application

≯℡__Kan透↙ 提交于 2019-12-12 05:49:50
问题 I am using MvvmCross v3.5 to build an iOS application. Whenever the application goes into the background I am expecteing SaveState to be called in the view model. However it never gets called. I have tried this both on the simulator and a device. Am I missing something. This works in the Android version of the app, so I think I have set it up correctly. Has anyone else got this issue? Any help would be appreciated. 回答1: I think in Xamarin you need to implement UIApplicationDelegate

Structure for MVC4 Survey Web App

允我心安 提交于 2019-12-12 05:14:26
问题 I am trying to figure out the model structure for a survey app, using the MVC architecture. Actually it is a Q&A section within a larger WebApp. I have about 120 questions and they will all have set options for answers, no written answers. Currently I have 3 tables: Question(id, QuestionText) Answer(id, Userid, Questionid, AnswerOptionId) AnswerOption(id, Option) - example: Yes, No, 1-10, etc I am trying to figure out how to build my viewmodel and view. I can't just have something like: @Html