I have a parent View that is xaml-binded to a ViewModel (the viewmodel is declared in the xaml).
This parent view can then display a child View (via NavigationService, aka navigation:Frame).
The parent view never goes out of scope, but I want the new child View to share the parent's ViewModel.
How can i do this? Because by declaring t...
I have an editor template (Views/Shared/EditorTemplates/HORDER.ascx) which inherits
System.Web.Mvc.ViewUserControl<CCOK2.Models.HORDER>
My viewmodel has a one-to-many relationship which I use Html.EditorFor in order to render multiple HORDERS
<%: Html.EditorFor(model => model.PEOPLE.HORDERS, new {fred="hello"})%>
Eventually w...
I got this error on my unit test:
Assert.AreEqual failed. Expected:<ShizoMe.Web.ViewModel.AccountViewModel>. Actual:<ShizoMe.Web.ViewModel.AccountViewModel>.
This is the code for my test:
[TestMethod]
public void Register_Prevents_Duplicate_Users()
{
var controller = GetAccountController();
var model = new A...
I have a view model -
public class MyViewModel
{
public int id{get;set;};
Public SomeClass obj{get;set;};
}
public class SomeClass
{
public int phone{get;set;};
public int zip{get;set;};
}
So on my controller when I post back MyViewModel it has all the values for all the fields...but when I do
return RedirectoAction("Som...
Summary:
If you use ASP.NET MVC 2's templates to render a DropDownList, how would you access the list of options if they are stored in the top level View's Model.property? Also, is there some [DataAnnotation] way to associate this list? Links to examples would be very helpful.
Background:
In ASP.NET MVC 2, you can create a custom cl...
I'm building an Asp.net MVC 2 application.
I have an entity called Team that is mapped via public properties to two other entities called Gender and Grade.
public class Team
{
public virtual int Id { get; private set; }
public virtual string CoachesName { get; set; }
public virtual string PrimaryPhone { get; set; }
...
A generally accepted way to pass all data to a view is to have a single data model with references to both your domain model and additional data for things like drop down lists (DDL).
However, partial views (view templates too) receive only a portion of the main model, not able to access the root of the Model sent to the original view. ...
I have a class called "PropertyFeature" which simply contains PropertyFeatureID and Description. It's a proper model created through LINQ to SQL mapped to an SQL Server database table. An example instance/row would be:
PropertyFeatureID: 2
Description: "Swimming Pool"
The number of rows (PropertyFeatures) can of course grow and shrink ...
/Controllers/ViewModels?
/Views/ViewModels?
Other?
...
There is a form: "dropdownlist", "available items listbox" and "selected items listbox", button: Add.
"dropdownlist" is filled with values. OnDropdownChange "available items listbox" is populated with the values taken from db (ajax request). User, using Add button, moves elements from "available items listbox" to "selected items listbox...
Hi guys/gals,
Could someone help me with this issue. I'm trying to figure out how to check two values on a form, one of the two items has to be filled in. How do I do a check to ensure one or both of the items have been entered?
I'm using viewmodels in ASP.NET MVC 2.
Here's a little snip of code:
The view:
Email: <%=Html.TextBoxFor...
in VM, set ICommand like:
private RelayCommand<EventArgs> _myCommand = null;
public RelayCommand<EventArgs> MyCommand
{
get
{
if (_myCommand == null)
{
_myCommand = new RelayCommand<EventArgs>((e) =>
{
//....
}
...
Hi,
When working with Viewmodels from linq to sql I have an architectural problem.
When you have an object from your db (let's say "person"), and you load it in your viewmodel. After this in your view, when you try to acces referenced classes (let's say a person has children object which is a different table in db, and a different data...
I'm sticking on how to best present some data that's being dynamically generated from two different tables.
Given my query:
var assets = assetRepo.Find(x => x.LoginId == User.Identity.Name);
var accounts = repository.Find(x => x.AccStatus == "A" && x.LoginId == User.Identity.Name);
var query = from asst in assets
...
I'm writing an ASP.NET MVC 2 site where I have defined a custom ViewModel that I'm trying to use in a View. Unfortunately, I'm running into an error when using the ViewModel through a strongly-typed lambda expression.
My Code
Here's my ViewModel:
[CompareProperties(ComparisonProperty1="EmailAddress", ComparisonProperty2="Confirm...
I'm building an ASP.NET MVC 2 site where I'm currently implementing an OpenID sign-up form. Unfortunately, I'm foreseeing a possible security bug/vulnerability inside my architecture.
Here's how I want OpenID login to work:
User requests /Account/Login, Controller sends back OpenIDLogin View.
User enters their OpenID into the View, th...
My site has Users.
My site has Items.
Users can leave a Review of an Item.
Users can leave a Rating of an Item.
When users rate an Item, they rate it in different categories: a rating for build quality, a rating for usefulness, a rating for aesthetic appeal.
So, in my database, my Reviews table would have one entry and my Ratings tab...
I am using ViewModelLocator pattern. I have the following situation:
Page1<->VM1 => Navigate => Page2<->VM1 => Navigate => Page3<->VM3
=> Page 4<->VM4
=> Page 5<->VM5
I will show Page2 using VM1 but the controls that will take input w...
Newbie-ish questions ahead:
Where should I put my View Model declarations?
I created a file called "ViewModels.cs" in my Models folder.
I created a few View Model classes, including one called RatingViewModel:
using System;
using System.Collections.Generic;var
using System.Linq;
using System.Web;
namespace Web.Model
{
public class Vi...
When I create a view and bind it directly to one class which has the properties I want to show on the view, the fields (textboxes, etc.) for it are created automatically. But when I create a ViewModel to encapsulate more than one object with data, this doesn't happen. Is there any way to get that working for a specific object which is in...