Search code examples
c#jqueryasp.netajaxmodalpopup

Close Ajax Modal Popup after some Code in ItemCommand ASP.Net


I'm having trouble with closing a ModalPopup after a code sequence was executed. I am coding a filebrowser for my company and everything works fine except of downloading files. I use SignalR to invoke a virusscan before downloading the file. My Code looks like this:

if (e.CommandName == "DownloadFile")
            {
                string filename = ((Button)e.Item.FindControl("bt_file")).Text;
                if (transHub.doScanFile(filename, currentPathShort, shareType, MasterSessionID, SessionID, user))
                {
                    Downloader.DownloadFile(HttpContext.Current, currentPath + @"\" + filename);
                    mpe_download.Hide();
                }

                else
                {
                    lb_download_status.Text = "Virus found!";
                    mpe_download.Show();
                }
            }

The Download itself works fine but the modalpopup i am using to show the virusscan process is not closing when the download starts. I open the Popup from clientside JavaScript:

$(".download").on("click", function () {
    $find("mpe_download_bhvr").show();
    $("#download-progress").progressbar({ value: false });
})

Can you help me closing the PopUp just as the Download starts? Or am i doing it completely wrong?


Solution

  • I found no real solution for this but i did a small workaround. I invoke the download from JavaScript now and move the files zipped from my UserShare(Server with the files on it) to my Webserver and generate a direct link then. This is pretty secure and there is the possibility to download multiple files simultaneously. So im not using the Downloadhandler anymore and i can use a jQuery Dialog Popup to show informations.