KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Ok, this is weird. I cannot use BindAttribute 's Include and Exclude properties with complex type nested objects on ASP.NET MVC. Here is what I did: Model: public class FooViewModel { public Enquiry Enquiry { get; set; } } public class Enquiry { public int EnquiryId { get; set; } public string Latitude { get; set; } } HTTP POST action: [ActionName("Foo"), HttpPost] public ActionResult Foo_post( [Bind(Include = "Enquiry.EnquiryId")] FooViewModel foo) { return View(foo); } View: @using (Html.BeginForm()) { @Html.TextBoxFor(m => m.Enquiry.EnquiryId) @Html.TextBoxFor(m => m.Enquiry.Latitude) <input type="submit" value="push" /> } Does not work at all. Can I only make this work if I define the BindAttribute for Enquiry class as it is stated here: How do I use the [Bind(Include="")] attribute on complex nested objects?
Tags (comma-separated)
Save Edits
Cancel