Thứ Tư, 27 tháng 8, 2014

Confirmation message after clicking the ActionLink in MVC

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
public ActionResult ConfirmationDialog()
{
return View();
}
From action create view as like below
ConfirmationMessage
ConfirmationMessage1
View (index)
@{
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>
OUTPUT:
ConfirmationMessage2
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