473,414 Members | 1,947 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Stopping somebody from losing changes when they navigate away from a page.

UJ
I have a page where the user can make changes to some DB stuff. It's not
saved until they hit the save button. I'd like to have it so that if they
attempt to navigate somewhere else, I give them a warning (and preferably
the ability to stop them) if they don't want to lose their changes. In other
words - an 'Are you sure you want to do this?' message box.

Can anybody help me on how to do this?

TIA - J.
Nov 19 '05 #1
9 4140
The only way I can think of acomplishing this is through JavaScript. I don't
know the exact code off the top of my head but if you ask in a JavaScript
news group or just google for it I'm sure you could find it.

It is important to note that if the user has JS disabled that solution would
not work.

"UJ" wrote:
I have a page where the user can make changes to some DB stuff. It's not
saved until they hit the save button. I'd like to have it so that if they
attempt to navigate somewhere else, I give them a warning (and preferably
the ability to stop them) if they don't want to lose their changes. In other
words - an 'Are you sure you want to do this?' message box.

Can anybody help me on how to do this?

TIA - J.

Nov 19 '05 #2
Here's some server side code that uses javascript to display a confirmation
message.

myDeleteButton.Attributes.Add("onclick", _
"return confirm('Are you sure you want to delete?');")

In this example, the Delete button will post back only if the person
confirms they want to delete. Otherwise your server code is never called in
response to the button click.

Here's a more detailed analysis of your options, including a free control
that can handle many of the options for you.
http://SteveOrr.net/articles/ClientSideSuite.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"UJ" <fr**@nowhere.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
I have a page where the user can make changes to some DB stuff. It's not
saved until they hit the save button. I'd like to have it so that if they
attempt to navigate somewhere else, I give them a warning (and preferably
the ability to stop them) if they don't want to lose their changes. In
other words - an 'Are you sure you want to do this?' message box.

Can anybody help me on how to do this?

TIA - J.

Nov 19 '05 #3
That doesn't appear to be what he's looking for, I got the impression if
someone tries to nav from his page, regardless of wether they interacted with
the page itself (ie: they hit the back button) a message box pops up.

"Steve C. Orr [MVP, MCSD]" wrote:
Here's some server side code that uses javascript to display a confirmation
message.

myDeleteButton.Attributes.Add("onclick", _
"return confirm('Are you sure you want to delete?');")

In this example, the Delete button will post back only if the person
confirms they want to delete. Otherwise your server code is never called in
response to the button click.

Here's a more detailed analysis of your options, including a free control
that can handle many of the options for you.
http://SteveOrr.net/articles/ClientSideSuite.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"UJ" <fr**@nowhere.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
I have a page where the user can make changes to some DB stuff. It's not
saved until they hit the save button. I'd like to have it so that if they
attempt to navigate somewhere else, I give them a warning (and preferably
the ability to stop them) if they don't want to lose their changes. In
other words - an 'Are you sure you want to do this?' message box.

Can anybody help me on how to do this?

TIA - J.


Nov 19 '05 #4
UJ,
You can dio this with the javascript OnUnLoad event...

Detailed documentaion and sample are available at following page

http://msdn.microsoft.com/library/de...s/onunload.asp
Sreejith
"UJ" wrote:
I have a page where the user can make changes to some DB stuff. It's not
saved until they hit the save button. I'd like to have it so that if they
attempt to navigate somewhere else, I give them a warning (and preferably
the ability to stop them) if they don't want to lose their changes. In other
words - an 'Are you sure you want to do this?' message box.

Can anybody help me on how to do this?

TIA - J.

Nov 19 '05 #5
UJ
Yes. I don't want a delete button per se. I want it that if they have made
changes (which I already know) they get a message asking them to confirm the
losing of the changes.

Let me ask this - what all can you do in the page unload event? Can you stop
the unloading from happening? What I really want is to have a way to say -
the page is unloading, check a few things and stop it from unloading if need
be.

TIA - J.

"Jason L Lind" <Ja********@discussions.microsoft.com> wrote in message
news:C3**********************************@microsof t.com...
That doesn't appear to be what he's looking for, I got the impression if
someone tries to nav from his page, regardless of wether they interacted
with
the page itself (ie: they hit the back button) a message box pops up.

"Steve C. Orr [MVP, MCSD]" wrote:
Here's some server side code that uses javascript to display a
confirmation
message.

myDeleteButton.Attributes.Add("onclick", _
"return confirm('Are you sure you want to delete?');")

In this example, the Delete button will post back only if the person
confirms they want to delete. Otherwise your server code is never called
in
response to the button click.

Here's a more detailed analysis of your options, including a free control
that can handle many of the options for you.
http://SteveOrr.net/articles/ClientSideSuite.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"UJ" <fr**@nowhere.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
>I have a page where the user can make changes to some DB stuff. It's not
>saved until they hit the save button. I'd like to have it so that if
>they
>attempt to navigate somewhere else, I give them a warning (and
>preferably
>the ability to stop them) if they don't want to lose their changes. In
>other words - an 'Are you sure you want to do this?' message box.
>
> Can anybody help me on how to do this?
>
> TIA - J.
>
>


Nov 19 '05 #6
You may also be able to take advantage of the client side OnClose event.
Here's more info:
http://www.mozilla.org/docs/dom/domr...dow_ref56.html

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Sreejith Ram" <Sr*********@discussions.microsoft.com> wrote in message
news:0D**********************************@microsof t.com...
UJ,
You can dio this with the javascript OnUnLoad event...

Detailed documentaion and sample are available at following page

http://msdn.microsoft.com/library/de...s/onunload.asp
Sreejith
"UJ" wrote:
I have a page where the user can make changes to some DB stuff. It's not
saved until they hit the save button. I'd like to have it so that if they
attempt to navigate somewhere else, I give them a warning (and preferably
the ability to stop them) if they don't want to lose their changes. In
other
words - an 'Are you sure you want to do this?' message box.

Can anybody help me on how to do this?

TIA - J.

Nov 19 '05 #7
This is IE Specific Code

<script language="javascript">
window.attachEvent( "onbeforeunload", Window_OnBeforeUnload ) ;

function ConfirmBeforeUnload()
{
var result = window.confirm("'Are you sure you want to do this?");
if(!result)
{
return(false);
}
}
</script>

if this doesnt work, you may also want to try the same with
window.onunload = ConfirmBeforeUnload;
Sreejith

"Sreejith Ram" wrote:
UJ,
You can dio this with the javascript OnUnLoad event...

Detailed documentaion and sample are available at following page

http://msdn.microsoft.com/library/de...s/onunload.asp
Sreejith
"UJ" wrote:
I have a page where the user can make changes to some DB stuff. It's not
saved until they hit the save button. I'd like to have it so that if they
attempt to navigate somewhere else, I give them a warning (and preferably
the ability to stop them) if they don't want to lose their changes. In other
words - an 'Are you sure you want to do this?' message box.

Can anybody help me on how to do this?

TIA - J.

Nov 19 '05 #8

This should help you.
http://aspnet.4guysfromrolla.com/articles/101304-1.aspx
"UJ" <fr**@nowhere.com> wrote in message news:#$**************@TK2MSFTNGP09.phx.gbl...
I have a page where the user can make changes to some DB stuff. It's not
saved until they hit the save button. I'd like to have it so that if they
attempt to navigate somewhere else, I give them a warning (and preferably
the ability to stop them) if they don't want to lose their changes. In other
words - an 'Are you sure you want to do this?' message box.

Can anybody help me on how to do this?

TIA - J.

Nov 19 '05 #9
Check this out.
http://aspnet.4guysfromrolla.com/articles/101304-1.aspx
"UJ" <fr**@nowhere.com> wrote in message news:#$**************@TK2MSFTNGP09.phx.gbl...
I have a page where the user can make changes to some DB stuff. It's not
saved until they hit the save button. I'd like to have it so that if they
attempt to navigate somewhere else, I give them a warning (and preferably
the ability to stop them) if they don't want to lose their changes. In other
words - an 'Are you sure you want to do this?' message box.

Can anybody help me on how to do this?

TIA - J.

Nov 19 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Richard Bell | last post by:
Newbie question ... please respond to group I'm trying to open/navigate to a url. How can I tell when the page is fully loaded? Testing suggest that window.open returns before the page is...
32
by: Neil Ginsberg | last post by:
We're using SQL Server 7 with an Access 2000 MDB as a front end with ODBC linked tables. I recently created a new set of tables for the app, and users are complaining that unsaved data is being...
1
by: Perre Van Wilrijk | last post by:
Hi, I've got a full text index which works fine, SQLSERVER2000/WIN 2000 SERVER. The system requires to update indexes immediately, so I use a timestamp field to enable this. No problems so...
0
by: katheo via AccessMonster.com | last post by:
Hello, I am using a data access page on a local secure server. As the user changes information, the data updates automatically in the database. But when the user goes to close the page, they get a...
0
by: tafs7 | last post by:
Hello, I have a custom datagrid control that works great. But I was thinking about adding some functionality to it. Currently, I use the datagrid to display one record at a time, and with item...
3
by: bbdobuddy | last post by:
Hi, I was reading this previous post on how to prompt the user if they want to save their changes before they exit the form. I found this piece of code but am not sure where to put it ...
2
by: Assimalyst | last post by:
Hi, I have a javascript that checks a form for changes, if it has any it alerts the user before they navigate away from the page. it can be disabled on a submit button click by adding ...
2
by: JonBosker | last post by:
I have a form developed in ASP.net and as such all of my controls are server controls and do not have access to onchange events. What I need is a javascript program to detect changes. Here is...
5
by: chromis | last post by:
Hi there, I've recently been updating a site to use locking on application level variables, and I am trying to use a commonly used method which copies the application struct into the request...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.