简体   繁体   中英

Updating view by calling Action Method from Javascript

I have a javacript Like this:

<script>
    function GetFromDate() {    
        var dt1 = document.getElementById('fromDate').value;
        var dt2 = document.getElementById('toDate').value;
        var url = "Statistics/Excel/"  + dt1 + "!" + dt2;        
        window.location.href = url;
        return false;

    };
</script>

and in controller my ActionResult is like this:

 public ActionResult Excel(string id)
        {
              \\ View Creation
               if(SomeLogic)
                  {
                         \\Excel Download Options
                  }
          return View(viewModel);
       }

Though it is perfectly working with the Excel Downloading option but it is not returning the View. Any Suggestions? For more information "viewModel" object contains the perfect data to be displayed.

如果您的响应返回文件下载,那么这将算作您的Http响应,您将无法在同一操作中进行重定向。

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