Not allow submit if data changed

D

David

Using VS2005 and .Net 2.0
I want to be able to keep the user from moving to another web page if they
have selected the "Edit" link button on a FormView (or any view for that
matter), have changed any of the data in bound controls and do not click on
the "Update" link button. Can anyone help? Thanks.

David
 
B

bruce barker \(sqlwork.com\)

this is just simple javascript. create a variable that is updated on any
value changed (by attaching script to the onchange event of each control).

the following is air code

<body onunload="return doConfirm()" onsubmit="changesSaved =true;">
<script>
var changesSaved = true;
function doConfirm() {
if (changesSaved ) return window.confirm("You have not saved you
changes, cancel navigate?");
return true;
}
</script>
<input type=text onchange="changesSaved =false;">

note: at form load, with client script you could attach the onchange handler
(be sure to delegate any existing routines).

-- bruce (sqlwork.com)
 
D

David

The textbox ia asp textbox so I have to set attribute in Sub Page_Load.
However, when I try to reference the control I get an error. The textbox is
in a FormView inside a EditItemTemplate section. How do I reference this
control in my VB sub? Thanks.

David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,905
Latest member
Kristy_Poole

Latest Threads

Top