mvc弹出提示框 C#


在Controller中实现在页面弹出提示框,具体代码如下:

 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         }
View Code

说明:可以根据需要指定跳转路径。

参考:

1.在mvc中弹出提示框

2.mvc弹出提示框

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM