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

How do I know when the user makes changes on a web form?

Hi All:

I have a web form that is displaying some data. What I want to do is:

- Set a flag when the user modifies any data on the form
- Ask the user if the changes are to be discarded when the user hits the exit button
- If user says Yes/OK I continue and quit the screen
- If user says Cancel I stop and return to the screen.

Here is what I have tried:

In the page_load event I have added the following code:

cmdCancel.Attributes.Add("onclick", "return confirm('Quit without saving?')")

But this causes it to fire even if there is no change - I (my client) want this to fire only if there is a change.

So I tried to add the same line in the _TextChanged event of a textbox control. The idea being once the user saves the form contents by hitting 'Save' I will use cmdCancel.Attributes.Remove("onclick") and add it back when _TextChanged detects a change.

This is not working right - I guess the way I have tried to implement it is flawed.

Is there anything other way I can do this?

Any help would be much appreciated.

TIA!

Vinay
vi******@nospam.yahoo.com
Nov 17 '05 #1
1 1462
"Vinay" <vi*****@nospam.acionyx.com> wrote in message news:e4**************@TK2MSFTNGP12.phx.gbl...
Hi All:

I have a web form that is displaying some data. What I want to do is:

- Set a flag when the user modifies any data on the form
- Ask the user if the changes are to be discarded when the user hits the exit button
- If user says Yes/OK I continue and quit the screen
- If user says Cancel I stop and return to the screen.

Here is what I have tried:

In the page_load event I have added the following code:

cmdCancel.Attributes.Add("onclick", "return confirm('Quit without saving?')")

But this causes it to fire even if there is no change - I (my client) want this to fire only if there is a change.

So I tried to add the same line in the _TextChanged event of a textbox control. The idea being once the user saves the form contents by hitting 'Save' I will use cmdCancel.Attributes.Remove("onclick") and add it back when _TextChanged detects a change.

This is not working right - I guess the way I have tried to implement it is flawed.

Is there anything other way I can do this?
You'll have to do this client-side, with JavaScript.
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com

Nov 17 '05 #2

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

Similar topics

1
by: Vinay | last post by:
Hi All: I have a web form that is displaying some data. What I want to do is: - Set a flag when the user modifies any data on the form - Ask the user if the changes are to be discarded when...
8
by: Galina | last post by:
Hello I have 6 dependent list boxes on my ASP page:  Faculty;  Lecturer;  Course;  Course occurrence;  Group;  Week commencing date. When faculty is selected, lists of lecturers and...
5
by: Bazza Formez | last post by:
Hi there, I am *very* new to this... so please excuse poor terminology etc. I am building a small content management system.. and have just managed to get an asp.net page up & running that edits...
4
by: Rob Kroese | last post by:
I've got a form with a datagrid that displays a list of items, along with several textboxes, comboboxes, etc., that display the details for the selected item. The columns in the datagrid and the...
1
by: Dean Slindee | last post by:
In my application there is a main form with a tabcontrol. On each page in the tabcontrol is a panel upon which is painted a "sub" form. The main form acts as the "application host", while the...
0
by: No bother | last post by:
The record source for a form I use is based on a query, which has several layers of subqueries with quite a number of joins. Needless to say this record source is not updateble. However, the data...
30
by: Charles Law | last post by:
Here's one that should probably have the sub-heading "I'm sure I asked this once before, but ...". Two users are both looking at the same data, from a database. One user changes the data and...
2
by: G Gerard | last post by:
Hello I have noticed that whenever I set a form's RecordSource property in code it launches the form's OnActivate event. In one of my application I set a form's RecordSource to zero lenght...
6
by: lucyh3h | last post by:
Hi, In one of my pages, I use javascript (AJAX) to populate one mulitple select field based on user's click event on another control. I noticed that when I navigate back to this page by clicking...
4
by: sharsy | last post by:
Hello, I have setup an Access Database which about 7 people can enter data into. We have had a few problems where a 'fairy' has mysteriously been changing data in the table that they're not...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
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
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...

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.