zoukankan      html  css  js  c++  java
  • MVC 弹出提示框

    第一种弹框成功后要刷新界面 

    [HttpPost]   
            public ActionResult Add(Maticsoft.Model.Project.ProjectMoneyPlan model)   
            {   
                model.Money = new Maticsoft.Model.Struct.DRMB(model.Money).ToDouble().ToString();   
                Maticsoft.BLL.User.LoginUser login = new Maticsoft.BLL.User.LoginUser();   
                model.Creater = login.Email;   
                try  
                {   
                    if (bll.Exist("Pro_MoneyPlan", "where ProCode='" + model.ProCode + "' ", "ProCode") && bll.Exist("Pro_MoneyPlan", "where Year=" + model.Year , "Year") && bll.Exist("Pro_MoneyPlan", "where Month=" + model.Month, "Month"))   
                    {   
                        ///弹框   
                       string script = String.Format("<script>alert('数据已经存在!');location.href='{0}'</script>",  Url.Action("Add"));      
                       return Content(script ,"Text/html");                  
                    }   
                    else  
                    {   
                        bll.Add(model);   
                        return View("List");   
                    }   
                }   
                catch (Exception ex)   
                {   
                    return new Maticsoft.BLL.Error().DoError(ex);   
                }   
            }   

    第二种弹框成功后不刷新界面:

    [HttpPost]   
            public ActionResult Add(Maticsoft.Model.Project.ProjectMoneyPlan model)   
            {   
                model.Money = new Maticsoft.Model.Struct.DRMB(model.Money).ToDouble().ToString();   
                Maticsoft.BLL.User.LoginUser login = new Maticsoft.BLL.User.LoginUser();   
                model.Creater = login.Email;   
                try  
                {   
                    if (bll.Exist("Pro_MoneyPlan", "where ProCode='" + model.ProCode + "' ", "ProCode") && bll.Exist("Pro_MoneyPlan", "where Year=" + model.Year , "Year") && bll.Exist("Pro_MoneyPlan", "where Month=" + model.Month, "Month"))   
                    {   
                       ViewData["ProName"] = SelecOpption.GetOpption("PRO_B", "", "Code,Name");//获取项目名称   
                       ViewData["Year"] = GetYear();   
                       ViewData["Month"] = GetMonth();   
                       ///弹框   
                       ViewBag.isExist = false;   
                       return View();   
                    }   
                    else  
                    {   
                        bll.Add(model);   
                        return View("List");   
                    }   
                }   
                catch (Exception ex)   
                {   
                    return new Maticsoft.BLL.Error().DoError(ex);   
                }   
            }   

    前台:

    @if (ViewBag.isExist == false)   
    {   
        <script type="text/javascript">   
            alert("您要添加的数据已经存在!")   
        </script>   
    } 
  • 相关阅读:
    图标字体IcoMoon 使用
    JS 寻找孩子并打印路径
    为什么要用on()而不直接使用click
    setTimeout 虚假的“异步”
    解决Ajax.BeginForm还是刷新页面的问题
    .net生成Excel,并下载
    C#判断文件是否正在被使用
    sql为数字添加千分位(也就是钱的格式)
    HotelIInventory项目小结
    一步一步实现FormsAuthentic验证登录
  • 原文地址:https://www.cnblogs.com/xiaoqi742709106/p/4275401.html
Copyright © 2011-2022 走看看