OnChildChanged Not firing from TryUpdateModel call

OnChildChanged Not firing from TryUpdateModel call

Old forum URL: forums.lhotka.net/forums/t/10542.aspx

EbenK posted on Wednesday, July 20, 2011


I am working with an MVC 3 application using CSLA 4.0, and I have set in the global.asax to use the CslaModelBinder.  I have a top level object that derives from BusinessBase<T> (I will call it Labor), and that object has a child collection (LaborLogList) that derives from BusinessListBase<T> that is made up of objects (LaborLog) that derive from BusinessBase<T>.


I need to have some properties update on the Labor object whenever the LaborLogList has been changed (ie: something was inserted into the collection, removed from the collection, or updated in the collection).  In order to achieve this requirement, I created an override for OnChildChanged at the Labor object level, and I am easily able to capture the collection changed events (insert and remove), but I am having some trouble in trying to capture the update events.  I expected to be able to just listen for the property name that I expect to change through e.PropertyChangedArgs.PropertyName, but the child changed event is never being fired for the properties that I have updated through my UI.


After further investigation of this, it seems that the any property that I update from the UI will not fire the OnChildChanged event at the parent level.  Here is an sample from  the controller method I am using:


if (TryUpdateModel(logVM))
Labor labor = Labor.GetByOID(returnId, true);


It would appear that the TryUpdateModel method does not fire the Csla OnChildChanged event.  The property values are changing, but the event is not being seen at the parent level.  Does anyone have any ideas on why this may be happening, or how I could get around it?



Copyright (c) Marimer LLC