473,471 Members | 1,695 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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
Jul 21 '05 #1
1 1943
"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

Jul 21 '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...
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: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.