0

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?

SamuraiJack
  • 5,131
  • 15
  • 89
  • 195
  • hi see if this post can help you to achieve what you trying to do http://stackoverflow.com/questions/11861271/confirmation-message-box-in-webapplication – Max Aug 13 '14 at 04:32
  • @Max no brother this is not what I am looking for. Because I do not want to display the confirmation box from the client side just when the user click the button. But instead I want to start the execution of the c# code when user clicks on it and after it is done executing first 10-20 lines it is then when I want to prompt user for confirmation if he wants to proceed further. – SamuraiJack Aug 13 '14 at 04:35
  • 1
    maybe try to split the function make the first part(10 -20 lines) and in the end of it register client script that will popup Confirm message box and in case of YES run the next function for download – Max Aug 13 '14 at 04:42
  • I think @Max has got the right solution here – Prescott Aug 13 '14 at 06:10

1 Answers1

0

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;
    }    
}
Max
  • 156
  • 9