When I use the default model binding to bind form parameters to a complex object which is a parameter to an action, the framework remembers the values passed to the first request, meaning that any subsequent request to that action gets the same data…
I am trying to get UpdateModel to populate a model that is set as only an interface at compile-time. For example, I have:
// View Model
public class AccountViewModel {
public string Email { get; set; }
public IProfile Profile { get; set; }
}
//…
Some decimal and decimal? properties in my view model are marked as "Percent" data type, along with other data annotations, for example:
[DataType("Percent")]
[Display(Name = "Percent of foo completed")]
[Range(0, 1)]
public decimal? FooPercent {…
I have a collection of objects on my Model that I'm rendering in a View by using EditFor function, and I have an EditorTemplate which is responsible for actually rendering each object.
@Html.EditorFor(model => model.MyObjects)
This has worked well…
I am trying to bind a string route parameter to Enum Type like below
public static async Task Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = "ValidateKey/{keyType}/{key}")]HttpRequestMessage req, KeyType…
First; I know that I should not need to test the internals of MVC but I REALLY need a suite a tests around data flowing into our system.
How can I, I hope without mocking all of HTTP context, test that objectA (form collection, dict, collection,…
MVC3 non-sequential index hidden inputs for model binding..
Does it matter if they go before, after, in the middle of the other related inputs to be posted?
Does it matter at all where they end…
I'm working on an ASP.NET MVC2 app. I've come to realize a very surprising, yet amazing thing that MVC does behind the scenes having to do with the ModelState and model binding. I have a ViewModel which has a whole bunch of data - some fields being…
I have a simple Poco-Model using abstract classes, and it seems not to work with the Default ModelBinder of Asp.net MVC 2.
One Item has several Objects in a collection, all using the same abstract base class.
Model:
public partial class Item
…
On MVC3, is there a way to decorate a ViewModel property in order to get the DefaultModelBinder to use a different name for it in the request?
For example, suppose you have the following view model:
public class SomeModel
{
public string…
I am developping my first application in Asp. I am using the environment Asp.NET MVC 3.
I have a controller Action that has a single parameter. The type of this parameter is a complex object.
public ActionResult MyAction(ComplexObj obj) {
…
I have a simplified test scenario useful for asking this question: A Product can have many Components, a Component can belong to many Products. EF generated the classes, I've slimmed them as follows:
public partial class Product
{
public int Id…
The Model:
public class MyObject
{
public IList Entries;
}
public class Entry
{
public string Name { get; set; }
}
If I use the default EditorFor(model => model.Entries) the name/id values are:
I've been reading the MVC 3 source code trying to understand what semantics I should adhere to if I override DefaultModelBinder.BindModel() or even implement IModelBinder.BindModel().
It's unclear to me what "state" BindModel() should leave other…
I have a struct which works much like the System.Nullable type:
public struct SpecialProperty
{
public static implicit operator T(SpecialProperty value)
{
return value.Value;
}
public static implicit operator…