Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Confirming leaving the page.....

Reply
Thread Tools

Confirming leaving the page.....

 
 
UJ
Guest
Posts: n/a
 
      08-10-2005
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.


 
Reply With Quote
 
 
 
 
Curt_C [MVP]
Guest
Posts: n/a
 
      08-10-2005
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
 
Reply With Quote
 
 
 
 
UJ
Guest
Posts: n/a
 
      08-10-2005
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:...
> 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



 
Reply With Quote
 
=?Utf-8?B?U3JlZWppdGggUmFt?=
Guest
Posts: n/a
 
      08-10-2005
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.
>
>
>

 
Reply With Quote
 
Curt_C [MVP]
Guest
Posts: n/a
 
      08-10-2005
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:...
>
>>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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Confirming who asp.net is running as? darrel ASP .Net 6 06-14-2005 07:43 PM
Confirming Certification =?Utf-8?B?Z3drZW5ueQ==?= Microsoft Certification 2 12-01-2004 11:21 AM
Confirming Deletes in a DataGrid =?Utf-8?B?TXBob3ph?= ASP .Net 1 08-06-2004 06:19 AM
Confirming Delete for a asp:ButtonColumn in asp:datagrid.. RSB ASP .Net 6 05-19-2004 04:27 PM
Confirming MCSE credentials Richard MCSE 4 10-06-2003 01:45 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57