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

Alert for unsaved data on page

In my website we have left panel having different links, our requirement when user clicks on any link and enter any detail on page without save/submit, and then he moves to next link on left panel an alert should be generated to user before the page load for new link happens. In that way an alert for unsaved data can be shown.

Note:- technology/languaage used should be:- VS 2005 asp.net 2.0 using C#, javascript

Thanks in Advance
Apr 1 '09 #1
2 3796
tlhintoq
3,525 Expert 2GB
Sounds like a good requirement. But if you are putting this out for bids, you should post it under Jobs.

This forum is used when people have questions about the code they've written but have run up against problems or errors and need help figuring out the source of the problem.

My compliments on how well you have described what your goals are and your intended plan of action to get there. Not everyone does that as well.
But... What is your question for the volunteers here?
Please visit the Posting Guidelines for tips on how to ask questions to get the best help.
Apr 1 '09 #2
Frinavale
9,735 Expert Mod 8TB
Well, since you're using JavaScript already in your solution you are probably aware that this solution will require JavaScript.

You're going to have to write a function that will keep track of any changes that happen to your controls.

You are going to have to set every control on your page to call this when a change occurs....so for every TextBox, set it to call the function that tracks changes during the onkeydown event...for every DropDownList, set it to call the function during the onchange event......etc etc.

Some controls (like calendars) will postback to the server when they are changed...so the server needs to be able to be able to indicate that a change has been made as well. Therefore, you'll probably have to store the boolean value that indicates whether or not changes have been made in a HiddenField so that it is available in both the server and client side code.

You can use the onbeforeunload JavaScript event to let the user cancel leaving your page.

So, the onbeforeunload event will have to call a function that retrieves the boolean value that's being used to track changes.

The onbeforeunload event happens every time the page is about to unload. This means that it happens any time a full page postback occurs.

Therefore all of your buttons, links, and anything else will have to indicate that the page should be unloaded without prompting the user.

So you need another function that registers any control that posts back to the server.....

So really, the method that handles the onbeforeunload event will have to check if any changes have been made, and check if any of your controls caused the page to unload before deciding whether or not to prompt the user.


Happy coding

-Frinny
Apr 3 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: David Horowitz | last post by:
Hi folks, I want to be able to store and retrieve UNSAVED Word documents as BLOBs. I got all the info for storing them if they're already saved on the file system. But what if they're not...
1
by: IVer Erling Årva | last post by:
I have a frameset where one frame contains a menu and the other the screens where the contents change depending on what the user clicks in the menu. Is there any relatively easy way to give the...
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...
4
by: PH | last post by:
Does anyone know how to have the pop-up javascript alert, Response.Write("<script language=javascript>alert('HEY!');</script>); , pop-up after the page has been posted back? I am pressing a...
4
by: markalroberts | last post by:
Hi, I wish to ask warn the user that there are unsaved changes (if there are) and allow them to cancel navigating away/closing the browser. Investigation leads me to believe the...
1
by: neoret | last post by:
Hello. I need a helping hand to help me send an unsaved dokument through a POST call. I have added functionality to word and want to send a unsaved document through a POST call. This works...
1
by: ChalkStream | last post by:
Well, it was saved onto my USB. Then I opened it, edited it, left it. When I came back someone had switched user and when I logged back in every thing crashed and I lost all the work. I restarted it...
5
by: nic829 | last post by:
I am trying to write a code such that when user close the browser or netvigate to other page, a message box will show up. <SCRIPT> function closeIt() { event.returnValue =...
4
by: clentoc | last post by:
I'm pretty new to javascript so this may well be a really basic error, but I've spent hours trying to fix it with no joy. I have written some code which looks in a CSV file, filters it depending...
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
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
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.