MVC 弹出框、确认框

在MVC控制器里控制前台弹出对话框和基于Page的Web页面有些少出入,下面几种方法简单描述下:

单纯弹出:

  • return Content(@"<script>alert('xxxxxxxx');</script>");

弹出&转向:

  • var script = String.Format("<script>alert('修改成功!');location.href='{0}'</script>", Url.Action("Index"));
    return Content(script, "text/html");

确认框 :

@Html.ActionLink("删除", "Delete", new { id = item.ID }, new { onclick="return confirm('确定要删除?')"})

posted @ 2021-01-03 23:36  SunKeep  阅读(367)  评论(0编辑  收藏  举报