473,414 Members | 1,888 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.

no suggestions on this one??

Hi. I have posted this question three times in this newsgroup as well as
microsoft.public.scripting.jscript and have get no answer yet. Now I dont
know if my question is too stupid or too weird, though usually my stupid
questions get some funny answers. I am gona try once more before I give up
on this one.

I need to ask the user whether to save the information on a page to a
sql server when exiting or navigating away, so I am using this code when
clicking the X button (top right close button). Button8 (is an asp.net
server control) does
that(save to database) when clicked so I am reusing
it in my javascript:

//this code is launched in the OnBeforeUnload event in the <body> section
function HandleOnClose()

{

if (event.clientY < 0)

if (confirm("OK to save changes. Cancel to exit without saving.") )
__doPostBack('Button8','')

}

The code above works fine, problem comes with the following code that I am
using when the user clicks a link to another page, code
__doPostBack('Button8','') is never executed. is there a simple work around
for what I want to do?:
// this code is launched when clickin in my page's links
function goToAnotherPage()

{

if (confirm("OK to save changes. Cancel to show Another Page without
saving.") ) __doPostBack('Button8','');

window.navigate("another_page.aspx");

}
Nov 19 '05 #1
3 1235
You'll need to do exactly what you are avoiding and that is
modifying the links on that page to call your JavaScript
function to see if changes have been made (I'm assuming you
have some sort of DirtyFlag that gets set if you change anything
on the form) and prompting for the save.

We have found that our users expect to stay on the same page
after the save (if they click ok). Then, if the click the link to
exit again, it should exit without prompting them because they
have not changed anything.

--
2005 Microsoft MVP C#
Robbe Morris
http://www.robbemorris.com
http://www.masterado.net/home/listings.aspx

"Alejandro Penate-Diaz" <al********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi. I have posted this question three times in this newsgroup as well as
microsoft.public.scripting.jscript and have get no answer yet. Now I dont
know if my question is too stupid or too weird, though usually my stupid
questions get some funny answers. I am gona try once more before I give up
on this one.

I need to ask the user whether to save the information on a page to a
sql server when exiting or navigating away, so I am using this code when
clicking the X button (top right close button). Button8 (is an asp.net
server control) does
that(save to database) when clicked so I am reusing
it in my javascript:

//this code is launched in the OnBeforeUnload event in the <body> section
function HandleOnClose()

{

if (event.clientY < 0)

if (confirm("OK to save changes. Cancel to exit without saving.") )
__doPostBack('Button8','')

}

The code above works fine, problem comes with the following code that I am
using when the user clicks a link to another page, code
__doPostBack('Button8','') is never executed. is there a simple work
around
for what I want to do?:
// this code is launched when clickin in my page's links
function goToAnotherPage()

{

if (confirm("OK to save changes. Cancel to show Another Page without
saving.") ) __doPostBack('Button8','');

window.navigate("another_page.aspx");

}

Nov 19 '05 #2
I know I need to check for changes in my forms first, but that doesn't
changes my question, I still want to postback to the server and after that I
want to navigate away, not to stay in the same page. How come I can postback
and close te window but I can not postback and navigate away??

Thanks, alejandro.

"Robbe Morris [C# MVP]" <in**@turnkeytools.com> wrote in message
news:uB*************@TK2MSFTNGP10.phx.gbl...
You'll need to do exactly what you are avoiding and that is
modifying the links on that page to call your JavaScript
function to see if changes have been made (I'm assuming you
have some sort of DirtyFlag that gets set if you change anything
on the form) and prompting for the save.

We have found that our users expect to stay on the same page
after the save (if they click ok). Then, if the click the link to
exit again, it should exit without prompting them because they
have not changed anything.

--
2005 Microsoft MVP C#
Robbe Morris
http://www.robbemorris.com
http://www.masterado.net/home/listings.aspx

"Alejandro Penate-Diaz" <al********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi. I have posted this question three times in this newsgroup as well as
microsoft.public.scripting.jscript and have get no answer yet. Now I
dont know if my question is too stupid or too weird, though usually my
stupid questions get some funny answers. I am gona try once more before I
give up on this one.

I need to ask the user whether to save the information on a page to a
sql server when exiting or navigating away, so I am using this code when
clicking the X button (top right close button). Button8 (is an asp.net
server control) does
that(save to database) when clicked so I am reusing
it in my javascript:

//this code is launched in the OnBeforeUnload event in the <body> section
function HandleOnClose()

{

if (event.clientY < 0)

if (confirm("OK to save changes. Cancel to exit without saving.") )
__doPostBack('Button8','')

}

The code above works fine, problem comes with the following code that I
am
using when the user clicks a link to another page, code
__doPostBack('Button8','') is never executed. is there a simple work
around
for what I want to do?:
// this code is launched when clickin in my page's links
function goToAnotherPage()

{

if (confirm("OK to save changes. Cancel to show Another Page without
saving.") ) __doPostBack('Button8','');

window.navigate("another_page.aspx");

}


Nov 19 '05 #3
A couple of suggestions...

1. Store a hidden flag on the client that can be read from the server
that tells the server side code that you're done with the page. When
you do the postback and the server side code is complete, the last
thing you do is check this flag and if it indicates that you are done
it redirects the page using response.redirect to the new page.

2. If you really need the page to postback, redisplay the current page
and then redirect to the new page then repeat step 1 but instead of
using response.redirect use RegisterStartupScript to insert some
javascript at the end of the form that automatically redirects the page
to the new page.

3. An advanced solution (and one of my favorites) is to use
asynchronous CallBacks which are still not officially supported in the
current version of the .Net Framework. Callbacks allow you make
requests to the server side code via xml without submitting the entire
page. This creates very efficient use of bandwidth and allows you to
dynamically update the contents of a page without having to post back
to the server (for example). You could use a callback to send the data
you wish to be saved to the server then continue on without waiting for
the results or redisplaying the page.
For more information check out Dino Espito's article from MSDN Magazine
at
http://msdn.microsoft.com/msdnmag/is...e/default.aspx
You can skip most of the 2.0 stuff and scroll down to the section
titled "Script Callbacks in ASP.NET 1.x"

Nov 19 '05 #4

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

Similar topics

1
by: linux newbie | last post by:
Hi all java experts, sorry to ask stupid question again, because i am a java newbie, i would like to have some suggestions/comparsions of good java IDE tool with gui feature (that enables me to...
3
by: Jason Daly | last post by:
I am looking for suggestions on book titles. I want great books for: ASP (VbScript) SQL PHP CSS XML Suggestions for or against any titles?
10
by: Ron Ruble | last post by:
I'd like to get suggestions from some of the folks here regarding tools and processes for a new, small development team. I'm starting a new job next week, and part of the fun is being able to...
2
by: Steve | last post by:
Hi; I am looking for suggestions about how to solve a problem using tsql. I have been asked to create a report concerning 4 tables. Each of the 4 tables is in its own database. The 4...
5
by: Mark Reed | last post by:
I am just starting out learning C#... mainly via self study. I am looking to get away from the networking/management hole I've found myself in and expand my resume to include development skills. ...
1
by: Brian Basquille | last post by:
Hello all. Have been working on the Air Hockey game on and off for a couple of weeks now.. but have had plenty of other assignments to keep me busy along with it. But i would like some...
26
by: Frank Samuelson | last post by:
I love Python, and it is one of my 2 favorite languages. I would suggest that Python steal some aspects of the S language. ------------------------------------------------------- 1. Currently...
0
rnd me
by: rnd me | last post by:
Purpose: Allows you to create "presets" for text form inputs. "Lightweight and simple to setup, it adds a lot of convenience for ~1kb of code." Only one function, two parameters: First...
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
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:
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
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
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,...

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.