473,387 Members | 1,812 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,387 software developers and data experts.

Form events

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
Nov 19 '05 #1
1 929
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.

--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
Read my weblog:
Followers of the IHttpHandler
http://clariusconsulting.net/vga
"bbdobuddy" <bb*******@discussions.microsoft.com> wrote in message
news:96**********************************@microsof t.com...
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

Nov 19 '05 #2

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

Similar topics

5
by: Richard Cornford | last post by:
I am interested in hearing opinions on the semantic meaning of FORM (elements) in HTML. I have to start of apologising because this question arose in a context that is not applicable to the...
0
by: jphelan | last post by:
I have a subform that works fine until you import it into a new database when it crashes if you try to open it in either disign or form view. The form, "Attendees_Subform" in my application was...
10
by: Drakier Dominaeus | last post by:
This is my first time posting here, so please forgive me if I do anything incorrectly. I've been learning C# and working with different things and decided I wanted to get into Multi-Threading....
5
by: RAJ | last post by:
hi plz tell me how to know "how window is going to close"... i have to right code for X button of forms... plz telll me thanks bye
5
by: [Yosi] | last post by:
Why I can't catch the Form lost focuse event ? I mad a FORM , I want to print message each time I moved to another application my my desktop . I thryed the following but not work . ...
18
by: Colin McGuire | last post by:
Hi - this was posted last weekend and unfortunately not resolved. The solutions that were posted almost worked but after another 5 days of working on the code everynight, I am not further ahead....
2
by: thomasp | last post by:
Using VB 2005 Beta. I have a form containing a DataGirdView. The cell enter, cell validating, row enter, row validating events have a good bit of code that gets excuted for each of these...
7
by: Miro | last post by:
I can use the property of the Form to remove the "x" from the top of the form. Is there a way in VB to leave the X there but program something so you cannot close the form? Or like an ONCLOSE...
0
by: hmm | last post by:
Hi all I have two problems: Problem #1: I'm using a .NET Form with the property 'FormBorderStyle' set to 'None'. The idea is to completely cover the area of that Form with a UserControl. In...
8
by: hoofbeats95 | last post by:
I don't think this should be this complicated, but I can't figure it out. I've worked with C# for several years now, but in a web environment, not with windows form. I have a form with a query...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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,...

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.