Working with fields that are not in the root layer of the model

Jun 23, 2013 at 3:12 PM
I'm having problems getting this to work with a field that's not in the route layer of my view model.
My view Model looks like so:
public BookingViewModel()
public BookingModel {get;set;}
public PresentationData {get;set;}

I have a method
public ActionResult Edit (BookingModel model)


Then in my View I have
@Html.AntiModelInjectionFor(o => o.Booking.Booking_ID)

Unfortunatley this doesn't work. However I decorate the ValidateAnitModelInjectionAttribute I get an exception thrown:

The hidden form field named value __Booking.Booking_ID was missing. This is created by the Html.AntiModelInjection methods. Ensure the name used on your [ValidateAntiModelInjectionAttribute("!HERE!")] matches the field name used in Html.AntiModelInjection method.
Jan 5, 2014 at 5:21 PM
Try changing your attribute from -


That should do the trick.