简体   繁体   中英

Is it possible to stop execution of code behind at certain point and ask for confirmation and then proceed?

I usually use

ScriptManager.RegisterStartupScript(this, this.GetType(), "pop", "<script>alert('Claim Saved Successfully with Claim No: " + ClaimNo + "');var currentPageUrl =document.location.toString().toLowerCase();window.location.assign(currentPageUrl);</script>", false);

in code behind to pop up a message to the user that the entry has been saved successfully. But my problem with this is that it does not show in a scenario when along with saving the entry I am also downloading a file.

I save an entry in the database and then generate a pdf file from the saved data and download it. All this on a single button click. I want to show a pop up message to the user after the entry has been saved in the database and then ask him if he wants to proceed and download the file? Is it possible? If yes how?

i am not sure but maybe something like this run your 20 line of code in some function befor the download process then run some thing like this

     ScriptManager.RegisterStartupScript(page,this.GetType(), "temp","javascript:Confirmopen();
",true);

function Confirmopen()    
{    
    if (confirm(" Download  file ?"))    
    {   
        enter code here 
        call server side function for download
    }
    else   
    {   
        return false;
    }    
}

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