Hey guys
I'm just wondering where people are creating their SelectList - in the action or the view.
I have seen examples of both and the one that makes the most sense to me is doing it in the action and have the view model have a property of type SelectList.
On the other hand, I have seen examples where people have the view model h...
I'm looking for some opinions on two different approaches to ViewModel definition
I have a Company class
public class Company
{
public string Name { get; set; }
public int CountryID { get; set; }
}
For the Create and Edit views I need a list of Countries to populate a DropDownList for CountryID selection. I can see two broad ...
Imagine I have a UserControl that shows a parking lot (my favorite analogy) with cars of different colors. You can select a car, and in a separate UserControl (in a separate project) statistics of the selected car are displayed.
Now a user wants a button on the car statistics UC, 'Next car of same color'. When selected it should show ...
In my ASP.NET MVC2 application, I have a ViewModel class called UserCreateViewModel.
In this class, there are a number of properties that directly map to a LINQ-to-SQL class, called User. I'm using AutoMapper to perform this mapping and it works fine.
In my Create action of the UserController, I receive a partially complete UserCreateV...
Ok, I have a ViewModel that looks like this:
public class UserLogin
{
[Required]
public string EmailAddress { get; set; }
[Required]
public string Password { get; set; }
}
My controller looks like this:
[HttpPost]
public ActionResult LogIn(UserLogin model)
{
if (!ModelState.IsValid)
{
// ...
}
}
...
Hey guys
Just wondering how how people handle Authorization when using MVVM and/or View Models.
If I wasn't using VM's I would be passing back the Model and it would have a property which I could check if a user can edit a given object/property but when using MVVM I am disconnecting myself from the business object... and thus doen't ...
I have a model that looks something like this:
public class SampleModel
{
public static SampleModel Create()
{
return new SampleModel
{
Boolean = true,
// set several more properties...
Colors = new SelectList(new[] { "Red", "Green", "Blue" }, "Green")
};
}
pub...
Hi!
I'm trying to return a different view if a condition is met. I want to preserve the Model passed into the view from the action.
protected override void OnActionExecuting(ActionExecutingContext filterContext)
{
var subAction = filterContext.RequestContext.RouteData.Values["subaction"].ToString();
var action ...
Hello,
its said that 1 ViewModel has 1 View.
1 View is for me a UserControl. What if my UserControl has different areas filled with data from different entities, do I have then several Views and need to build several ViewModels?
e.g: I display in a UserControl 3 entities: customer(listbox),order(datagrid),product(datagrid). Each of th...
I'm using a TreeView with a Hierarchical Data Template to bind to a View Model hierarchy, my problem is i have multiple child collections of different types (same base class though). Seems relatively simple to use the template to bind one of the collections but i'm struggling to work out how to do both.
class ParentViewModel
{
List<...
This the html form:
<input id="picture1" name="Input_Pictures" type="file" value="" />
<input id="picture2" name="Input_Pictures" type="file" value="" />
<input id="picture3" name="Input_Pictures" type="file" value="" />
I also tried:
<input id="picture1" name="Input_Pictures[]" type="file" value="" />
<input id="picture2" name="Inpu...
I'm getting totally lost and confused on how to use the new strongly typed Html.DropDownListFor helper on ASP.NET MVC 2.0 R2
In the View I'm writting:
<%= Html.DropDownListFor(m => m.ParentCategory, new SelectList(Model.Categories, "CategoryId", "Name", Model.ParentCategory), "[ None ]")%>
<%= Html.ValidationMessageFor(m => m.ParentCa...
I'm trying to follow the MVVM pattern laid out here: http://msdn.microsoft.com/en-us/magazine/dd419663.aspx#id0090097 I have this in my MainWindowResources.xaml file:
<DataTemplate DataType="{x:Type vm:VendorsViewModel}">
<vw:Vendors/> <--- I get a "Can't put a page in a style" error in blend with this
</DataTemplate>
and I'...
What is the recommended "cleanest" way to manage a partial that appears on many views and also requires a viewmodel (assume it needs to get some data from a DB).
...
I have the problem that parts of the TreeView Controltemplate need to change depending on the state of the bound (ItemsSource) ViewModels. For example the little expander icon needs to be exchanged with a different drawing based on each items ViewModel state. Additonally based on the state of each ViewModel the child items need to be arr...
I am using Microsoft MVC and C#. I have a usercontrol (example.ascx) created and at the top I'm inheriting System.Web.MVC.ViewUserControl<PostTransferViewModel>
Now, while my model name is appended to ViewUserControl, I get "The name 'Model' does not exist in the current context" and "The name 'Html' does not exist in the current contex...
I'm trying to create a strongly typed view model as John Sheehan suggests here. Where should it go? I can make arguments to myself for Model, View, and Controller.
...
Doing something like this:
<DataTemplate DataType="{x:Type vm:AllCustomersViewModel}">
<vw:AllCustomersView />
</DataTemplate>
works in a ResourceDictionary for when I want to apply a ViewModel to a UserControl as root, but how do I the same thing when I have a UserControl inside of a Page? Would I create a ResourceDictionary for all ...
Hello all,
Lets assume I have the following 3 entities: Customer,Order,Product which interact in the View with the CustomerOrderProductViewModel.cs:
I have several controls like listbox,datagrid,etc.. to display those entities in my View.
Those Entities shall be fetched sort of eager loading. That would mean I have 3 sqldatareader in ...
Hi,
I am trying to come up with a model design to solve the follwoing problem:
I have files (plain text and xml) which I want to be able to represrnt them in a view in ASP.NET, also, I would need to detect certain words in lines and keep track of them. So, we can imagine I have the following
CFile: List<Message> CertainMessages
M...