Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / July 2005

Tip: Looking for answers? Try searching our database.

Form events

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
bbdobuddy - 22 Jul 2005 14:46 GMT
Hi,

I have an ASP.net application that has some javascript written for the
onbeforeunload event which asks the user if they want to save changes before
they leave.  However, there is a problem with this because if I click the
Save Changes button it asks me the same question as in the onbeforeunload
event because when the button is clicked it does a postback which causes that
event to fire.  

Is there a way that I can get around that so that question doesnt' come up
when I click the save button?

Also is there a way that I can Monitor controls so that the question in the
onbeforeunload event fires only when one of those controls has changed
Victor Garcia Aprea [MVP] - 23 Jul 2005 23:57 GMT
Hi,

Use an 'isDirty' flag or such. Writing Javascript code attach to the
onchange events of the different elements you want to monitor for changes
and set this flag to true on any changes. A function attached to the onclick
of your Save button should also set this flag to false. Then the function
used to display the alert message will do so only in cases isDirty is true.

Signature

Victor Garcia Aprea
Microsoft MVP | ASP.NET
Read my weblog:
Followers of the IHttpHandler
http://clariusconsulting.net/vga

> Hi,
>
[quoted text clipped - 13 lines]
> the
> onbeforeunload event fires only when one of those controls has changed

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.