Hi,
I have an aspx page with a number of web controls on it and one of these is
a cancel button. I want to check the page to see if the user has changed any
of the controls, i..e typed some text in a textbox, changed a dropdown etc
The reason I want to do this is when the user clicks cancel I want to notify
them that their changes will be lost using a popup or something.
My question is what is the best way to compare the page that was presented
to the user originally against the one they're cancelling? I'm thinking of
getting the hashcode of the viewstate or something like this....probabl y on
the wrong lines though.
any help appreciated.
thks 6 4368
Hi Tomas,
Thanks for that but it's not exactly what I want, probably didn't explain it
well enough.
I only want to show this pop up if the user has changed some values, so what
I really want is a mechanism to know if the user has changed anything, if
they have I show the popup otherwise I don't.
"Tomas" wrote: Hi Neil,
One very simple answer to this would be to use the <input type="reset" value="Cancel">
This will automatically reset all the controls on the form to their original values. If you want a pop up, just use the onclick event.
<input type="reset" onclick="return prompt('All your data will be lost. Continue?');" value="Cancel">
That is the simpliest way I know. Let me know if that helps,
Tom
"Neil" wrote:
Hi,
I have an aspx page with a number of web controls on it and one of these is a cancel button. I want to check the page to see if the user has changed any of the controls, i..e typed some text in a textbox, changed a dropdown etc
The reason I want to do this is when the user clicks cancel I want to notify them that their changes will be lost using a popup or something.
My question is what is the best way to compare the page that was presented to the user originally against the one they're cancelling? I'm thinking of getting the hashcode of the viewstate or something like this....probabl y on the wrong lines though.
any help appreciated.
thks
its more of javascript code than asp.net code
1. create a global javascript variable.. within script tag without being in
function
2. for all you webcontrols as a javascript onChange etc which will modify
the value of the variable created in 1.
3. the reset button will have a noclick set to another function that can
check the value of the variable and determine if it was modified.
4. if it was modified say something like
var modified = false // at the start on modification call
function SetModified()
{
modified = true;
}
function CheckForModific ation()
{
if(modified == true)
{
alert("you modified.. you sure you want to cancel ?");
return true;
}
else
{
return false;
}
}
This is all javascript based code. I do not recommend this method as you
will lose your ability to use validator controls etc. But again you might
not want to use them.
--
Regards,
Hermit Dave
( http://hdave.blogspot.com)
"Neil" <Ne**@discussio ns.microsoft.co m> wrote in message
news:60******** *************** ***********@mic rosoft.com... Hi Tomas,
Thanks for that but it's not exactly what I want, probably didn't explain it well enough.
I only want to show this pop up if the user has changed some values, so what I really want is a mechanism to know if the user has changed anything, if they have I show the popup otherwise I don't.
"Tomas" wrote:
Hi Neil,
One very simple answer to this would be to use the <input type="reset" value="Cancel">
This will automatically reset all the controls on the form to their original values. If you want a pop up, just use the onclick event.
<input type="reset" onclick="return prompt('All your data will be lost. Continue?');" value="Cancel">
That is the simpliest way I know. Let me know if that helps,
Tom
"Neil" wrote:
> Hi, > > I have an aspx page with a number of web controls on it and one of > these is > a cancel button. I want to check the page to see if the user has > changed any > of the controls, i..e typed some text in a textbox, changed a dropdown > etc > > The reason I want to do this is when the user clicks cancel I want to > notify > them that their changes will be lost using a popup or something. > > My question is what is the best way to compare the page that was > presented > to the user originally against the one they're cancelling? I'm thinking > of > getting the hashcode of the viewstate or something like > this....probabl y on > the wrong lines though. > > any help appreciated. > > thks
Hi Dave,
Yeh I was trying to avoid doing this in javascript... I was hoping there
would be a more generic way also that would apply to the whole page, so if
new controls are added I don't need to assign client side handlers to them.
I was thinking of comparing request and response objects or viewstate or
something....
"Hermit Dave" wrote: its more of javascript code than asp.net code 1. create a global javascript variable.. within script tag without being in function 2. for all you webcontrols as a javascript onChange etc which will modify the value of the variable created in 1. 3. the reset button will have a noclick set to another function that can check the value of the variable and determine if it was modified. 4. if it was modified say something like
var modified = false // at the start on modification call
function SetModified() { modified = true; }
function CheckForModific ation() { if(modified == true) { alert("you modified.. you sure you want to cancel ?"); return true; } else { return false; } }
This is all javascript based code. I do not recommend this method as you will lose your ability to use validator controls etc. But again you might not want to use them.
--
Regards,
Hermit Dave (http://hdave.blogspot.com) "Neil" <Ne**@discussio ns.microsoft.co m> wrote in message news:60******** *************** ***********@mic rosoft.com... Hi Tomas,
Thanks for that but it's not exactly what I want, probably didn't explain it well enough.
I only want to show this pop up if the user has changed some values, so what I really want is a mechanism to know if the user has changed anything, if they have I show the popup otherwise I don't.
"Tomas" wrote:
Hi Neil,
One very simple answer to this would be to use the <input type="reset" value="Cancel">
This will automatically reset all the controls on the form to their original values. If you want a pop up, just use the onclick event.
<input type="reset" onclick="return prompt('All your data will be lost. Continue?');" value="Cancel">
That is the simpliest way I know. Let me know if that helps,
Tom
"Neil" wrote:
> Hi, > > I have an aspx page with a number of web controls on it and one of > these is > a cancel button. I want to check the page to see if the user has > changed any > of the controls, i..e typed some text in a textbox, changed a dropdown > etc > > The reason I want to do this is when the user clicks cancel I want to > notify > them that their changes will be lost using a popup or something. > > My question is what is the best way to compare the page that was > presented > to the user originally against the one they're cancelling? I'm thinking > of > getting the hashcode of the viewstate or something like > this....probabl y on > the wrong lines though. > > any help appreciated. > > thks
"Tomas" <To***@discussi ons.microsoft.c om> wrote in message news:06******** *************** ***********@mic rosoft.com... Hi Neil,
One very simple answer to this would be to use the <input type="reset" value="Cancel">
This will automatically reset all the controls on the form to their original values. If you want a pop up, just use the onclick event.
Just a warning when you use the "reset" function mixed with postbacks:
the "original" value is the value that is written in the html, the *last time*
the page was received.
So: say you start with an empty form, the user adds some values and causes
a postback. After this a "reset" will not result in an empty form (as it would
have done before that postback), but in a form with values as they were
right after that postback.
Hans Kesting
Neil,
you can do that sort of a check on the server side. I misunderstood you
thinking you were looking to avoid roundtrip and even the notification if
there was no user activity other than click reset
what you can do is simple
either fetching the data again on user submission to cross check
or
store the values in a accessible location like for example writing to a
viewstate or session object or even a cache object
so now you have two copies of the data. The controls would reflect the state
as submited by the user. modified or not.
now you can do a parameter wise comparision.
--
Regards,
Hermit Dave
( http://hdave.blogspot.com)
"Neil" <Ne**@discussio ns.microsoft.co m> wrote in message
news:DE******** *************** ***********@mic rosoft.com... Hi Dave,
Yeh I was trying to avoid doing this in javascript... I was hoping there would be a more generic way also that would apply to the whole page, so if new controls are added I don't need to assign client side handlers to
them. I was thinking of comparing request and response objects or viewstate or something....
"Hermit Dave" wrote:
its more of javascript code than asp.net code 1. create a global javascript variable.. within script tag without being
in function 2. for all you webcontrols as a javascript onChange etc which will
modify the value of the variable created in 1. 3. the reset button will have a noclick set to another function that can check the value of the variable and determine if it was modified. 4. if it was modified say something like
var modified = false // at the start on modification call
function SetModified() { modified = true; }
function CheckForModific ation() { if(modified == true) { alert("you modified.. you sure you want to cancel ?"); return true; } else { return false; } }
This is all javascript based code. I do not recommend this method as you will lose your ability to use validator controls etc. But again you
might not want to use them.
--
Regards,
Hermit Dave (http://hdave.blogspot.com) "Neil" <Ne**@discussio ns.microsoft.co m> wrote in message news:60******** *************** ***********@mic rosoft.com... Hi Tomas,
Thanks for that but it's not exactly what I want, probably didn't
explain it well enough.
I only want to show this pop up if the user has changed some values,
so what I really want is a mechanism to know if the user has changed anything,
if they have I show the popup otherwise I don't.
"Tomas" wrote:
> Hi Neil, > > One very simple answer to this would be to use the <input
type="reset"> value="Cancel"> > > This will automatically reset all the controls on the form to their > original > values. If you want a pop up, just use the onclick event. > > <input type="reset" onclick="return prompt('All your data will be
lost.> Continue?');" value="Cancel"> > > That is the simpliest way I know. Let me know if that helps, > > Tom > > "Neil" wrote: > > > Hi, > > > > I have an aspx page with a number of web controls on it and one of > > these is > > a cancel button. I want to check the page to see if the user has > > changed any > > of the controls, i..e typed some text in a textbox, changed a
dropdown> > etc > > > > The reason I want to do this is when the user clicks cancel I want
to> > notify > > them that their changes will be lost using a popup or something. > > > > My question is what is the best way to compare the page that was > > presented > > to the user originally against the one they're cancelling? I'm
thinking> > of > > getting the hashcode of the viewstate or something like > > this....probabl y on > > the wrong lines though. > > > > any help appreciated. > > > > thks
Hi Dave,
Yeh I should have been clearer, its not a reset button but a link to return
to the previous page, so I wanted a way to notify the user that changes would
be lost if they didn't click save.
I think I'll probably end up doing a comparison between the original fields
and the ones on postback.
What I really hoped was for a very generic mechanism, like checking a hash
value of the original response against the postback or something, this way if
new controls are added etc I don't need to worry about editing the comparison
logic plus it could be used accross many pages.... maybe I want to much hey.
thanks for your help
"Hermit Dave" wrote: Neil,
you can do that sort of a check on the server side. I misunderstood you thinking you were looking to avoid roundtrip and even the notification if there was no user activity other than click reset
what you can do is simple either fetching the data again on user submission to cross check or store the values in a accessible location like for example writing to a viewstate or session object or even a cache object
so now you have two copies of the data. The controls would reflect the state as submited by the user. modified or not. now you can do a parameter wise comparision.
--
Regards,
Hermit Dave (http://hdave.blogspot.com) "Neil" <Ne**@discussio ns.microsoft.co m> wrote in message news:DE******** *************** ***********@mic rosoft.com... Hi Dave,
Yeh I was trying to avoid doing this in javascript... I was hoping there would be a more generic way also that would apply to the whole page, so if new controls are added I don't need to assign client side handlers to them. I was thinking of comparing request and response objects or viewstate or something....
"Hermit Dave" wrote:
its more of javascript code than asp.net code 1. create a global javascript variable.. within script tag without being in function 2. for all you webcontrols as a javascript onChange etc which will modify the value of the variable created in 1. 3. the reset button will have a noclick set to another function that can check the value of the variable and determine if it was modified. 4. if it was modified say something like
var modified = false // at the start on modification call
function SetModified() { modified = true; }
function CheckForModific ation() { if(modified == true) { alert("you modified.. you sure you want to cancel ?"); return true; } else { return false; } }
This is all javascript based code. I do not recommend this method as you will lose your ability to use validator controls etc. But again you might not want to use them.
--
Regards,
Hermit Dave (http://hdave.blogspot.com) "Neil" <Ne**@discussio ns.microsoft.co m> wrote in message news:60******** *************** ***********@mic rosoft.com... > Hi Tomas, > > Thanks for that but it's not exactly what I want, probably didn't explain > it > well enough. > > I only want to show this pop up if the user has changed some values, so > what > I really want is a mechanism to know if the user has changed anything, if > they have I show the popup otherwise I don't. > > "Tomas" wrote: > >> Hi Neil, >> >> One very simple answer to this would be to use the <input type="reset" >> value="Cancel"> >> >> This will automatically reset all the controls on the form to their >> original >> values. If you want a pop up, just use the onclick event. >> >> <input type="reset" onclick="return prompt('All your data will be lost. >> Continue?');" value="Cancel"> >> >> That is the simpliest way I know. Let me know if that helps, >> >> Tom >> >> "Neil" wrote: >> >> > Hi, >> > >> > I have an aspx page with a number of web controls on it and one of >> > these is >> > a cancel button. I want to check the page to see if the user has >> > changed any >> > of the controls, i..e typed some text in a textbox, changed a dropdown >> > etc >> > >> > The reason I want to do this is when the user clicks cancel I want to >> > notify >> > them that their changes will be lost using a popup or something. >> > >> > My question is what is the best way to compare the page that was >> > presented >> > to the user originally against the one they're cancelling? I'm thinking >> > of >> > getting the hashcode of the viewstate or something like >> > this....probabl y on >> > the wrong lines though. >> > >> > any help appreciated. >> > >> > thks
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Steven Scaife |
last post by:
Below is my ASP page, I have changed the update to read DRIAL which doesn't
exist, shouldnt this throw an error, or if the connection cannot be made
shouldnt it throw an error as well
thanks in advance
<%@language="VBScript"%>
<% option explicit %>
<% response.buffer = True %>
|
by: foldface |
last post by:
Hi
I have only just become aware that form values posted to the server don't
need to be preserved in viewstate because asp.net preserves them anyway
separately from this.
2 questions
(1) What is the mechanism that preserves them? (Purely for academic interest)
(2) I have a property on a control that is added to the viewstate. With
trace on and some code that shows the contents of the viewstate I see
that information both in the viewstate...
|
by: Hadar |
last post by:
Hi,
I'm still a little bit confused with how managing a webcontrol state over
postbacks...
Should I use the form's post values to populate the control on the server
side when possible, or should I always use the viewstate mechanism?
For instance, I noticed that the TextBox webcontrol does not depend on the
viewstate.
I guess it uses the form to retrieve state (the input is submited of course)
|
by: Jim |
last post by:
I have a C# Web application that has 1 Web form that has 2 command buttons on
it with a label for output. I have a form level variable declared String
strName = "Jim"; right below where the buttons are declared by the form
designer. I have two event methods for my 2 command buttons. In the
Button1_Click event method I change the value of the form level variable
strName = "Kevin";. In the second event method, Button2_Click I check to see...
|
by: cFleury |
last post by:
This system works in a intranet w/ some 200 stations and this particular form
is retaining its values among different stations...like if I enter some
values in the form on station 1 walk to station 2 and call the form the
fields will be field w/the same info....
What can I do ?
Thanks
C.Fleury
| |
by: cFleury |
last post by:
I have an ASP.NET web form that is retaining values over different stations
on the network, how can I stop this behavior ?. I didn’t do anything special
to cause it.
Thanks
C.Fleury
|
by: fugaki |
last post by:
Hi everyone
I'm learning asp, and i downloaded this script to teach me how to post form data from a webpage to an access database. I put it on the server so i could make sure that it worked, and everything was fine, so i changed the variable names (the names of the form elements, and the names of the rows in access) so that it would be more correct to what i am using it for. Now once I did that, it gave me an error on line 24 which was the...
|
by: Nathan Sokalski |
last post by:
I have 2 private variables in my class that I need to remember the values of
between postbacks (or actually callbacks, since I am using AJAX). I want to
avoid using session variables, if possible. Is there any other way to have
VB.NET maintain the values of these variables between postbacks & callbacks?
Thanks.
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/
|
by: zybernau |
last post by:
a weird behaviour from my check box,
i am having one check box inside a form,
while checking i am setting values to the variables,
one of the variable has one more event triggered from that .
every thing goes fine , after all these, the check box state is not changed, at the initial click only, after that it works good
code format of mine
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
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 we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |