简体   繁体   中英

MVC: How to display a modal popup after calling the ActionResult

I need to display a modal popup once a button is pushed, I made it with JS, but the issue that the popup is displayed before the ActionResult is executed, so I had many bugs. If I remove the JS function from the button, the page is displayed correctly, but not a popup. A full .cshtml vue.

Here is the JS part:

<script type="text/javascript">
  $('#submitupload').click(function () {
    window.open('@Url.Action("Result", "Home")', "uploadFormSuccess", 
    "height=600,width=600,modal=yes,alwaysRaised=yes");

   });
</script>

Here is the ActionResult in the controller:

[HttpGet]
public PartialViewResult Result()
{
    try
    {
        return PartialView("uploadFormSuccess");
    }
    catch (Exception ex)
    {
        _logger.Error(ex.Message);
        return PartialView("Error");
    }
}

Does anybody know how to "oblige" the action of the button to go to controller first and display a modal popup?

您应该使用Ajax发送请求,并在上传完成后弹出对话框。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM