Confirmation message after clicking the ActionLink in MVC using Razor
Controller
Create view for the ConfirmationDialog to show the confirmation message.Ifclick ok it will redirect ConfirmationDialog
view else it stay in index view
view else it stay in index view
View (index)
@{
ViewBag.Title = “Home Page”;
}
ViewBag.Title = “Home Page”;
}
@Html.ActionLink(“Click to Confirm”, “Confirmation”, null, new { onclick = “return ConfirmationDialog()” })
<script type=”text/javascript”>
function ConfirmationDialog() {
if(confirm(“Are you sure to continue?”))
return true;
else
return false;
}
</script>
<script type=”text/javascript”>
function ConfirmationDialog() {
if(confirm(“Are you sure to continue?”))
return true;
else
return false;
}
</script>
OUTPUT:
If you click ok, it will redirect to the Confirmation.cshtml view
Không có nhận xét nào:
Đăng nhận xét