在mvc3控制器中显示警报消息

时间:2013-05-24 04:47:37

标签: jquery asp.net-mvc

    [HttpPost]
    public ActionResult BasicInfStep0( PricingPackModel pricingPackModel)
    {
        bool isEventSaved = false;
        try
        {
            string Zip = pricingPackModel.ZipCode;
            string AccCode = pricingPackModel.CustomerId;
            bool ischeck = pricingPackModel.IsNewAccount;
            isEventSaved = _crmClient.ValidateCodes(Zip, AccCode, ischeck, _authentication, _identity);

            if (isEventSaved)
            {
                return View("BasicInf");
                //return Json(isEventSaved, JsonRequestBehavior.AllowGet);



            }
            else
            {
                //return Json(isEventSaved, JsonRequestBehavior.AllowGet);
                //Console.WriteLine("");
                return Content("<script language='javascript' type='text/javascript'>alert('Enter the proper value for zipcode');</script>");


            }
        }
        catch (Exception)
        {
            throw;
        }


    }

我在我的控制器中使用此代码,它正在显示警报消息 但如果我点击OK按钮,它就不会回到原来的屏幕,只是显示一个白色的屏幕。

请帮帮我。

1 个答案:

答案 0 :(得分:1)

如果全部是javascript结果,那么您也可以尝试使用此

else
{
    return new JavascriptResult { Script = "alert('Enter the proper value for zipcode');" };
}