Many of functionalities are common during code development, cancel button functionality is one of them. I have developed it in MVC4 application in which I have used JQuery.
Add btnsubmit in view (.cshtml) page which should be as follows:
<input type="submit" value="Cancel" name ="Command" id ="btnsubmit"/>
JQuery code is as follows:
if ($("#btnsubmit").val() == "Cancel")
var output_value = confirm("Are you sure you want to cancel?")
If multiple buttons are present on the form then whenever page gets posted, id and value are used to recognize which button has been clicked. If user selects cancel then confirmation box will be gone.
If output_value is true then submit is performed. This way we can prevent POST action of form if user selects cancel.
No responses found. Be the first to comment...