更新於 2021/02/18閱讀時間約 1 分鐘

ASP.NET MVC ALERT訊息參考實例

    在controller內加上ShowData["message"]="mvc 測試";
    public ActionResult Login()
    {
    ShowData["message"]="mvc 測試";
    return View();
    }
    view內加上處理判斷
    @{
       if (ShowData["message"] != null)
      {
        script type="text/javascript"
          var message = @Html.Raw(Json.Encode(ShowData["message"]));
          alert(message);
        /script
        }
    }
    分享至
    成為作者繼續創作的動力吧!
    © 2025 vocus All rights reserved.