Sunday, 15 January 2012

c# - How to check if my model has changed on the view? -



c# - How to check if my model has changed on the view? -

i trying update list of items. want update items have changed on view.

for now, on controller have code

foreach ( var item in items ) { update(item); }

but need have

foreach ( var item in items ) { if(itemhaschanged(item)) { update(item); } }

i need have because don't want unnecessary updates , it's performance. don't want roundtrip database check if item has changed.

is possible check on view if item has changed ?

i using asp.net mvc 4...

maybe cache model before send view.

httpcontext.current.session["oldmodel"] = yourmodel;

and compare model in post action 1 cached.

if decide javascript think should take consideration user modify or disable javascript on browser.

c# asp.net-mvc performance asp.net-mvc-4

No comments:

Post a Comment