473,397 Members | 2,084 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,397 software developers and data experts.

Confirming leaving the page.....

UJ
I've got a page where users can make changes (enable and disable some
checkboxes.) I need to have it so that if they have made changes and go away
from the page, they will get prompted if they want to lose their changes
before the changes are actually saved. So I've got code that adds a
javascript window.confirm on unload to stop them. Problem is, the check
boxes are run at the server which means whenever somebody clicks one, the
page thinks it's unloading to it prompts them which isn't what I want. I
only want them to be prompted when they are going elsewhere.

Anybody have any suggestions on what I can do to fix this?

TIA - Jeffrey.
Nov 19 '05 #1
4 1632
UJ wrote:
I've got a page where users can make changes (enable and disable some
checkboxes.) I need to have it so that if they have made changes and go away
from the page, they will get prompted if they want to lose their changes
before the changes are actually saved. So I've got code that adds a
javascript window.confirm on unload to stop them. Problem is, the check
boxes are run at the server which means whenever somebody clicks one, the
page thinks it's unloading to it prompts them which isn't what I want. I
only want them to be prompted when they are going elsewhere.

Anybody have any suggestions on what I can do to fix this?

TIA - Jeffrey.


tie a local variable to the onBlur event of the checkbox

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com
Nov 19 '05 #2
UJ
I don't understand what you mean to put a variable in the onBlur event. Sure
I can set a local variable and now I know that something is happened. But
when the person clicks the checkbox, and the page is sent to the server, the
onunload event is called which fires, it sees that there has been a change
so it asks the user if they want to lose the changes then reloads itself.

Are you saying though - check for the variable in the onunload and if the
variable is set, don't do anything because that means that the page isn't
really going to unload - and then reset the variable ? I'm not sure how to
do that.

TIA - Jeffrey.

"Curt_C [MVP]" <software_at_darkfalz.com> wrote in message
news:uY**************@TK2MSFTNGP12.phx.gbl...
UJ wrote:
I've got a page where users can make changes (enable and disable some
checkboxes.) I need to have it so that if they have made changes and go
away from the page, they will get prompted if they want to lose their
changes before the changes are actually saved. So I've got code that adds
a javascript window.confirm on unload to stop them. Problem is, the check
boxes are run at the server which means whenever somebody clicks one, the
page thinks it's unloading to it prompts them which isn't what I want. I
only want them to be prompted when they are going elsewhere.

Anybody have any suggestions on what I can do to fix this?

TIA - Jeffrey.


tie a local variable to the onBlur event of the checkbox

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

Nov 19 '05 #3
one method would be setting a flag at client side when the check boxes are
clicked and validate that flag inside the unload function

This will be a global flag at client side, on page load set it to true

var FireUnloadPrompt = true;

check boxes will call a client side function oncheck / uncheck

chk1.Attributes.Add("onclick" , "ChecUncheck();")

ChecUncheck()
{
FireUnloadPrompt = false;
return(true);
}

in Window.Unload fucntion

if(FireUnloadPrompt)
code to call window.confirm...

Wouldnt this work?
"UJ" wrote:
I've got a page where users can make changes (enable and disable some
checkboxes.) I need to have it so that if they have made changes and go away
from the page, they will get prompted if they want to lose their changes
before the changes are actually saved. So I've got code that adds a
javascript window.confirm on unload to stop them. Problem is, the check
boxes are run at the server which means whenever somebody clicks one, the
page thinks it's unloading to it prompts them which isn't what I want. I
only want them to be prompted when they are going elsewhere.

Anybody have any suggestions on what I can do to fix this?

TIA - Jeffrey.

Nov 19 '05 #4
UJ wrote:
I don't understand what you mean to put a variable in the onBlur event. Sure
I can set a local variable and now I know that something is happened. But
when the person clicks the checkbox, and the page is sent to the server, the
onunload event is called which fires, it sees that there has been a change
so it asks the user if they want to lose the changes then reloads itself.

Are you saying though - check for the variable in the onunload and if the
variable is set, don't do anything because that means that the page isn't
really going to unload - and then reset the variable ? I'm not sure how to
do that.

TIA - Jeffrey.

"Curt_C [MVP]" <software_at_darkfalz.com> wrote in message
news:uY**************@TK2MSFTNGP12.phx.gbl...
UJ wrote:
I've got a page where users can make changes (enable and disable some
checkboxes.) I need to have it so that if they have made changes and go
away from the page, they will get prompted if they want to lose their
changes before the changes are actually saved. So I've got code that adds
a javascript window.confirm on unload to stop them. Problem is, the check
boxes are run at the server which means whenever somebody clicks one, the
page thinks it's unloading to it prompts them which isn't what I want. I
only want them to be prompted when they are going elsewhere.

Anybody have any suggestions on what I can do to fix this?

TIA - Jeffrey.


tie a local variable to the onBlur event of the checkbox

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com



You will have to turn off the auto-postback

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com
Nov 19 '05 #5

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

Similar topics

1
by: Rich | last post by:
Hello, I want to create a cookie that will expire in a few mintues after a user leaves my page so that they can return without having to login again if they were only gone for a few minutes. I...
3
by: Dag Sunde | last post by:
Both refreshing (by pressing F5 or otherwise) a page, and navigating away from a page leads to onUnload() triggering. Is it possible to determine if the user is leaving the page for another, or...
8
by: Zvonko | last post by:
Hi! Is it possible to capture an event when user leaves the page and execute some code? Not when he closes the window. Any ideas?
1
by: Rich | last post by:
Hello, I want to create a cookie that will expire in a few mintues after a user leaves my page so that they can return without having to login again if they were only gone for a few minutes. I...
3
by: Anburaja | last post by:
Hi, I want to get confirmation before leaving a page. If the selects Yes i want to leave the page else i want to retain the page in the browser. i tried with <body onbeforeunload="return...
3
by: =?Utf-8?B?Q2hyaXMgUm9kZW4=?= | last post by:
I am working on an ASP.NET application utilizing .NET 3.5. One page is using a multi-view with 10 views. UpdatePanels are used to navigate from one view to another. There are hundreds of fields and...
5
by: =?Utf-8?B?QW5keQ==?= | last post by:
As per the question really. Not trying to stop them leaving, but just detect WHEN they leave the site
1
by: Anonymous | last post by:
Which is the correct approach to disable buttons when leaving an aspnet page? Currently I have the following html, which disables buttons when pressing F5 in FireFox, which ofcourse can occur...
4
by: daveh551 | last post by:
Okay, I feel like this is probably a stupid question, but... I have accessed sites that are pushing some scam that, when you go to leave the page it will pop up a box saying, "No, don't go, let...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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.