Not allow submit if data changed

  • Thread starter Thread starter David
  • Start date Start date
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
 
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)
 
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

Back
Top