Visual InterDev
Determines whether an event that occurred on the client will be passed from the client to the server for processing. Available only in client script.
Syntax
thisPage.cancelEvent [=Boolean]
Parameters
Boolean
If set to true, the form will not be posted to the server to invoke the server event handler. If false (default), the form will be posted.
Remarks
A client action can cause a scripting object to invoke a server function to process the event. If an onbeforeserverevent event exists, it is called before the form is posted to the server.
A good use of the onbeforeserverevent event is to validate data on the client before posting the form to the server. If you then want to prevent the form from being posted, set the cancelEvent property to true.
Example
The following is an example of how to trap the button click event for a delete button. The script prompts the user to confirm the deletion before proceeding.
<SCRIPT LANGUAGE="Javascript">
function thisPage_onbeforeserverevent( obj, event ){
if (obj=="btnDelete"){
if(event=="onclick"){
if (confirm("Are you sure you want to Delete?")){
alert("Deleted per your request");
}
else {
alert("Delete cancelled");
thisPage.cancelEvent = true;
}
}
}
}
</SCRIPT>