I've been reading up on AutoMapper because of a response to one of my earlier questions here. It says that AutoMapper flattens complex domain models, but I need something that does the opposite. I need to wire up my view models (flattened domain models) to the complex domain models so that I can quickly transform a view model into a doma...
I'm not sure if this is a bug in the DefaultModelBinder class or what.
But UpdateModel usually doesn't change any values of the model except the ones it found a match for.
Take a look at the following:
[AcceptVerbs(HttpVerbs.Post)]
public ViewResult Edit(List<int> Ids)
{
// Load list of persons from the database
List<Person> peo...
If you have a select list set to multiple in ASP.NET MVC, how does the modelbinding work?
What does it return for your selected items, an array?
<SELECT NAME="toppings" MULTIPLE SIZE=5>
<option value="mushrooms">mushrooms</option>
<option value="greenpeppers">green peppers</option>
<option value="onions">onions</option>
...
This problem has been driving me crazy for several hours now...
In my domain, I have 2 entities that are related to each other Sku and Item. Each sku can have many items.
public class Sku
{
private readonly EntitySet<Item> items;
public Sku()
{
items = new EntitySet<Item>(AttachItems, DetachItems);
}
public...
I'll try to keep this short and concise.
I got my controller here...
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Edit(CustomObject myCustomObject)
{
...
}
Where myCustomObject looks great. But, if I want to save this using the entity framework, I need to do something like this...
[AcceptVerbs(HttpVerbs.Post)]
public Acti...
Is it possible to create a model binder for a generic type? For example, if I have a type
public class MyType<T>
Is there any way to create a custom model binder that will work for any type of MyType?
Thanks,
Nathan
...
I have an action method setup:
public ActionResult Delete(IList<Product> products)
And a table of products in my view. I have got Model Binding working so that on submit I can populate the products list. But I would like to populate it with only the products that are selected via a checkbox.
I think I could do it by changing the acti...
(That is, the model that you pass to the view and the model that you get back once the form posts.)
If not, is it better to do so anyways? What if there is data you are gathering that is beyond what the view page model has a property for?
...
Hi,
I'm passing a the type IEnumerable to my view, and for each item I output a html.textbox to enter the details into.
When I post this back to my controller, the collection is empty and I can't see why.
public class Item
{
public Order Order { get; set; }
public string Title { get; set; }
public doubl...
We are working with entities in our MVC controllers which are passed to strongly typed views.
How do we re-instantiate these entities in the controller with updated data when the form is posted in the view?
The form does not contain all the fields of the entity so all of the data needed to
re-instantiate the entities won't be there in ...
The question is in the title, actually - let's say I have a simple class like this:
public class Product {
public Int32 ID { get; set; }
public String Name { get; set; }
//...
}
When I use it in action method, like this:
public ViewResult DoSomething([Bind(Exclude="ID")]Product product] {
//...
}
what value will product.I...
I have a pair of views in my application that both display the same Editor Template for one of my model items; of the two views ("Add" and "Edit"), "Edit" works fine, but "Add" is returning null for the model when my controller action handles the post.
I found that if I give the "Add" view a custom ViewModel and call Html.EditorFor(p =>...
I am using the MVC validation library from link text. I chose this library because I am also using .NetTiers which generates all of the Validation Attributes using MS Enterprise Library Validation Blocks.
It works fine except that that model binding is automatically validating the object and populating the Validation summary. I believe...
Hello,
Does anyone know how to auto-populate the tinymce editor from the ASP.NET MVC model? In other words, what code do I need to use to set the contents of tinymce?
EDITED:
My problem is that tinyMCE is hiding my textbox contents. It opens blank, even though if I view the source of the page in my browser, it shows the correct info (i...
I am using ASP.NET MVC 2 Beta. I can create a wizard like workflow using Steven Sanderson's technique (in his book Pro ASP.NET MVC Framework) except using Session instead of hidden form fields to preserve the data across requests. I can go back and forth between pages and maintain the values in a TextBox without any issue when my model i...
HI,
I'm sure I'm missing something very obvious here so please forgive me.
I'm using MVC 2 Beta and I have a model that has several properties, strings, ints etc. the usual stuff.
It also has a byte array that contains an image.
I have an edit action method on my controller decorated with a [HTTPGet] attribute.
The method passes the m...
Hey all
I've got a View where I use a naming-convention on my text-fields, to indicate what should be done with the content once it is posted back to my controller.
The format is similar to:
<input type="text" name="RegistrationLine#ID" />
for updates
<input type="text" name="CreateRegistrationLine#LineNumber" /> for create
Now sinc...
I'd like to be able to swap model binders out on a per Controller or per ActionMethod basis.
AFAIK the only options supported by the framework are to bind a model binder to a specific type.
How could I change my model binder per Controller or per ActionMethod in a clean way?
...
I have a simple form in ASP.NET MVC. I am trying to post these results to a controller action and I am getting strange behavior.
The view is a simple HTML table:
Here is part of the HTML form View:
<form action="/Applications/UpdateSurvey" method="post"><table id=questionsTable class=questionsTable border=1>
<thead><tr><td>Name</...
The model validation doesn't evaluates the attributes linked to listbox values if you don't select at least one of them.
This way is not possible to do a model evaluation using DataAnnotations in order to inform required values.
The controller:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using S...