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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bootstrap 4: Exploring New Features

Learn how to use and navigate the new features included in Bootstrap 4, the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites.

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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.