Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - no suggestions on this one??

 
Thread Tools Search this Thread
Old 03-17-2005, 12:39 PM   #1
Default 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");

}




Alejandro Penate-Diaz
  Reply With Quote
Old 03-17-2005, 01:01 PM   #2
Robbe Morris [C# MVP]
 
Posts: n/a
Default Re: no suggestions on this one??
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" <> wrote in message
news:%...
> 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");
>
> }
>





Robbe Morris [C# MVP]
  Reply With Quote
Old 03-17-2005, 01:22 PM   #3
Alejandro Penate-Diaz
 
Posts: n/a
Default Re: no suggestions on this one??
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]" <> wrote in message
news:...
> 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" <> wrote in message
> news:%...
>> 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");
>>
>> }
>>

>
>





Alejandro Penate-Diaz
  Reply With Quote
Old 03-25-2005, 12:51 AM   #4
mszanto@hotmail.com
 
Posts: n/a
Default Re: no suggestions on this one??
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"



mszanto@hotmail.com
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need suggestions for motherboard / RAM / etc. bigal Hardware 0 07-26-2006 01:01 PM
DVD stores in LA-- suggestions?? G. M. Watson DVD Video 21 09-23-2005 11:06 AM
Re: Monitor suggestions PLEASE! Tom MacIntyre A+ Certification 2 03-06-2004 12:04 AM
Re: Monitor suggestions PLEASE! Mr widgetron A+ Certification 1 02-29-2004 12:39 PM
Any suggestions? havinfun69nospam@yahoo.com A+ Certification 7 11-03-2003 10:58 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

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