c# - ASP.NET MVC 2 Model Binding: How to debug a partially failed model binding on post back? -
We had a visual model that looked like this:
public class myViewModel { Public contract contract {set; Set;} Public Dealer Seller {get; Set;}} Public Sector Contract {Public Int Contract ID {get; Set;} // ... Various string properties are public ILIST & lt; Contract DAT> Contract: Get {Details; Set;} Publisher Dealer Vendor {Receive; Set;}}
The entire agreement coming back from the form was.
[HttpPost] Edit Public Action Result (Contract Agreement) {...}
Make all the binding form post values back into contract parameter properties gives.
When we sell the contract as a value item, all first levels of the contract fail to bind the "primitive" property. All IList & lt;> Properties are OK
Any ideas or we will need more information to solve this puzzle? Is there a way to test how MVC object changes parameters back to values? Does the seller have any way of not having an ILID, i.e., why does ILIT properties work properly?
Edit:
Specify exactly the object hierarchy names in all fields, for example, to bind the seller's name, for this, the "contract. Name is required. This prefix was done for us using ViewModel, but not done for us using the contract model. We have terminated it for all visual templates (partial view):
EditorFor (m => m.vendor, "vendor", "contract. Vendor")
The name of the "vendor" editor is the template "vendor. Cassaks" and "contract. Vendor" prefix of all form field names.
I think because ViewModel nested all data correctly to apply all properties to MVC. This would mean that the "loosely" form fields are not eligible by object prefixes, which will not be bound by parameter object names.
Simply download the project reference and debug through the default binders.
Comments
Post a Comment