Detection of data changes in a page

F

Frank Esser

Hallo,

I've got a project with about 10 pages. On each of them the user can do data
changes (mostly datagrid interactions; the datagrids are bound to datasets).

The user is able to jump to each page of my project without clicking on the
"save" button and he can also close the browser without saving.

My customer wants the user to be informed about loss of data. If any page is
left without saving data changes then on the same page a message should be
shown "Do you want to save data before leaving this page?" and there should
be two buttons "Yes"/"No" in a certain design (no javascript message box!).

So I have got big trouble with this problem.

First I implemented a javascript function that is called on each
"OnBeforeUnload" event of the HTML body. This function just checks for data
changes and if so then re-calls the same page again. So on server side I was
able to detect changes and put the request for saving to the page content.
But the "OnBeforeUnload" event is also fired on each server-roundtrip when
doing any datagrid operation such as selecting an item.

With the "OnBeforeUnload" event it is not possible to call a server function
directly, only client-side javascript is possible.

I am running out of ideas. Has anyone a tip for me to solve this general
problem?

Thanks a lot !!!
 
J

Josh

Do you have links between the pages? If so put the check there, before the
page redirects you can put in your mesage etc.

As for the User shutting the browser. I can see why they might want that
prompt, but it would not be standard "Web" behaviour. I would suggest you
just have an onscreen graphic that indicates the data is unsaved, which
changes when they save.
 
F

Frank Esser

Thank you, Josh.

There are links between my pages but for some reasons I can not use them for
a data change check.
The user can also navigate through my project by other technics and so that
does not work.

I thought there might be any workaround or general solution even if it is
not a common web behaviour to do anything on page unload.
I thought ASP.NET is a real alternative to windows forms applications...
Perhaps in one of the future versions there is a build-in solution for my
problem - I trust in Microsoft ;-)

I anyone else has any idea I would be a very lucky programmer....
 
G

Guest

You can make use of session variables here, keep an array in the session
having two coloumns one for the page name and other for the Save status, keep
updating this array whenever user clicks the save button, defaults the Save
status to No.

Now i whenever user jumps from one page to another just run a loop to check
for the save status in the session variable for the current page and then you
can take the appropriate action you can popup a winow where in you can ask
user about the confirmation and take the appropriate action.

Hope this Helps.
 
F

Frank Esser

Thanks a lot for your answer.

Yes, indeed, this would help me and I already thought about such a solution.
There are some disadvantages, but I think I will do it this way.

Disadvantages of this solution:
- Closing the browser will not check for data changes
- Jumping to another page will cause a redirect to the former page with
request for saving and then? I have to jump back to the intended page
afterwards. If there is another page between to display the save result it
would be difficult for me to handle the whole workflow with different states
and flags ("state machine"). It would be much more compfortable not to leave
the page where data changes occured.

Regards
Frank
 
G

Guest

I really dont know how you have implemented the Jumping between pages is it a
linear (clicking on Next) or its a non-linear like user can jump to any page
they want.
If you can give me some details about this then i can think on top of that
so that we can minimize the disadvantages.
 
F

Frank Esser

Hello,

to be honest: I did not tell you the whole story.
My ten pages are not called by a standard web browser but by a industrial
machine with an embedded terminal. This machine has a kind of primitive
self-written browser.
The page names are implemented in this browser and so the user can jump to
each page by a navigation panel that I can not influence.
So on server-side I have my session object and my page-load event to do
anything but I can not recognize the click on the navigation panel itself.
So I can not put a "was-it-saved-check" in a "on-navigation-click-event".

So you perhaps (and hopefully) understand why it is difficult for me to
implement a "data-changed-detection"...

The most difficult requirement spec in this project is that not only the
customers industrial machine as a terminal browser has to be served but as
well a standard browser in case of using e.g. a tablet PC. That means my
server architecture has to cover both client types.

I think it would go to much to detail to explain everything of this project
but I think it is a little bit more clear now what my problem is, isn't it
???
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top