Featured post
C# and ASP.NET custom property attributes and determining if properties changed -
i working on project want keep history of particular object. on save want method on object determine if has changed can call method save current state history. e.g. populate form object user makes changes (or possibly not) , submits from. want take original object , copy of object has been updated form , determine if has changed @ all. additionally may decide @ point properties don't matter (e.g. if name changes won't track it).
i'm thinking easiest/most flexible way accomplish if give properties care custom attribute [changetracked] , use reflection list of properties attribute , loop through them comparing a.property == b.property determine if have changed.
would work? there better/easier way handle this, sort of built in method can add object determine if values of properties have changed? whatever solution psudo code appreciated. point of clarification solution needs determine if value care has changed not if has been assigned since created i.e. if set name="bob" , "bob" before assignment not count change.
it ain't fancy, tried , true brute force method. add private property object named isdirty. properties want track, add isdirty=true property set routine. more complicated "do care" rules, code them property set.
the page button's click event can fire save event writes values textboxes , dropdowns object properties, calls object save method, tests isdirty property before doing anything.
- Get link
- X
- Other Apps
Comments
Post a Comment