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弹出提示框

 

 

posted @ 2013-10-02 16:28  博客园逛逛  阅读(4321)  评论(0编辑  收藏  举报