In many scenario, it necessary to pop up the confirm alert box while deleting ,saving and editing ย information in Asp .Net MVC application. So let us discuss about how can we achieve using JQuery code .
Controller
Create simple controller and generatingย view based on the controller as shown below.
View (index)
As shownย belowย code, we had createdย ConfirmationDialog function using javascript to show the popup with alert message. Next creating aย AcionLink controlย which will show the popupย by calling the javascript method in theย onclick event.
1 2 3 4 5 6 7 8 9 10 |
<script type="text/javascript"> function ConfirmationDialog() { if(confirm("Are you sure to continue?")) return true; else return false; } </script> @Html.ActionLink("Click to Confirm", "Confirmation", null, new { onclick = "return ConfirmationDialog()" }) |
OUTPUT:
If you click ok, it will redirect to the Confirmation view
Leave A Comment