VS2005 ASP.net - Lock Batch in Database

OK, I need some help with this one!

I have a default screen with a list of batches for the operators to work on...if operator 1 selects batch 123 I lock it so the other operators can't work on the same batch, by setting a flag in the database.  If operator 1 closes out the browser or clicks the home page button before they have completed the work on the batch...how can I reset this flag in the database so another operator can finish working on that batch of work?

I need to know when they have left the page either by clicking home or closing completely out so I can reset this flag?

Thanks,
Mark
smithmrkAsked:
Who is Participating?
 
UnifiedISCommented:
Here's a link but it sounds like capturing the browser close is unreliable.
http://stackoverflow.com/questions/3888902/javascript-detect-browser-close-tab-close-browser

Maybe a timer is the way to go.  You've probably encountered sites (like banking) that will log you out after a period of inactivity.  You would unlock the batch and send them batch to another page instead of logging them out.
0
 
UnifiedISCommented:
I don't think you can capture that with any asp.net events so you'll have to use javascript to capture the browser close/page leave.
If they click something, like a link to another page, you can handle it but closing the browser doesn't trigger anything natively.
0
 
smithmrkAuthor Commented:
OK, so how can I stop them from leaving the page with javascript unless the click the Close Button which will reset my flag?

Thanks,
Mark
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
smithmrkAuthor Commented:
I'm more concerned with them click the X on the browser how can I release that batch to someone else if that person clicks the X to close out before the batch is done.  I need to capture the browser closing and do a postback to update the database flag.

Mark
0
 
UnifiedISCommented:
MSDN has a technique with examples here:
https://code.msdn.microsoft.com/How-to-Detect-the-Web-737ef524

As it says:
  The sample demonstrates how to detect the browser close event.

It includes two parts:

1 Send ajax call every 20 seconds, to tell the server side that the page is still open.

2 Send ajax call when the browser is closed.
0
 
smithmrkAuthor Commented:
OK...I will look into that but I found something that I think will work for me, but I'm having one issue with it that maybe you can help me with...

Here is the code I found:
http://www.codeproject.com/Articles/20260/Save-Changes-on-Close-of-Browser-or-When-Exiting-t

The problem I'm having is I can NOT figure out the javascript: document.form1.submit();
It doesn't work with a Master Page...how can I get the above document.???.submit(); to work with a master page?

Thanks,
Mark
0
 
smithmrkAuthor Commented:
OK, so I looked at the link you sent me and forgive me but how can I use this code in VS2005?
Can you help with some sample code on how I would use the Javascript and how I can use that to tell the server the user has left to release the batch?

Thanks,
Mark
0
 
smithmrkAuthor Commented:
OK, this will work for me!

Thanks,
Mark
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.