mvc弹出提示框 C#
在Controller中实现在页面弹出提示框,具体代码如下:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 public ActionResult LoginCheck() 2 { 3 4 string userName = Request.Form["userName"]; 5 string password = Request.Form["password"]; 6 if (string.IsNullOrWhiteSpace(userName) || string.IsNullOrEmpty(password)) 7 { 8 var script = String.Format("<script>alert('用户名或者密码不能为空!');location.href='{0}'</script>", Url.Action("index","Common"));//Url.Action()用于指定跳转的路径 9 return Content(script, "text/html"); 10 } 11 12 return RedirectToAction("Index", "Home");//成功时的跳转路径 13 14 }
说明:可以根据需要指定跳转路径。
参考:
2.mvc弹出提示框