zoukankan      html  css  js  c++  java
  • MVC 中 注册不成功 或其他操作不成功 提示办法

    在Controller中 .cs

                      public  ActionResult AddUser(User u)

                        {

                                         ……

                                 try

                                  {

                                          ……

                                           GetInsertUser(u);        //  注册  或其他操作方法

                                           retutrn RedirectToAction("SHow","AllUser");

                                    }

                                   catch

                                    {

                                             ViewBag.IsError=true ;

                                             ViewBag.Meaage="对不起,注册失败!";  // 或其他操作失败信息

                                     }

                         }

          然后  在当前的视图(AddUser.cshtml) 页面的最低下加如下代码

              @{

                         if(ViewBag.IsError!=null && ViewBag.IsError )

                             {

                                   <script> alert("@ViewBag.Message")  </script>   // 注意alert里面的“”很重要!

                             }

                 }

  • 相关阅读:
    Redis分布式锁
    SpringCloud之服务网关gateway
    SpringCloud之服务注册中心Eureka、zookeeper、consul
    查询list对象
    获取当前列表值,返回图片路径展示刀前台
    js获取当前时间
    checkbox事件
    Python接口自动化测试(7):Jmeter安装与启动
    Python接口自动化测试(8):Jmeter发送请求
    Python接口自动化测试(6):Postman使用-jenkins集成
  • 原文地址:https://www.cnblogs.com/yingger/p/3422200.html
Copyright © 2011-2022 走看看