Click here to Skip to main content
15,904,153 members
Please Sign up or sign in to vote.
4.00/5 (3 votes)
See more:
How can I check whether the user actually clicked "save" and not "cancel"?

Files can be downloaded fine but I need to write to a Database after the user saves a file but dont want to write to it if they click cancel and dont actually save the file.

Basically something like:

C#
Response.ContentType = "application/ms-excel";
Response.AddHeader("content-disposition", "inline; file1.xls");
Response.WriteFile(randomFileName); 

If(user clicked cancel)
{
    // Do nothing
}
else if (user clicked save)
{
    // write to a database
}
Posted
Updated 22-Mar-11 2:29am
v2
Comments
niro shah 22-Mar-11 8:28am    
Hi,
write the event on submit button
Ankur\m/ 22-Mar-11 8:36am    
I have deleted your garbage answer (and comment). Don't behave as a troll or you will be thrown out.
Eduard Keilholz 22-Mar-11 8:33am    
w00t?
Sandeep Mewara 22-Mar-11 8:38am    
What is this? Trying to convey anything?

Erhm,

If you have two buttons on your WebForm, just doubleclick both of them. Visual Studio generates code for you (two methods) one method will be called when 'Save' is clicked, the other will be called when 'Cancel' is clicked.

Good luck!

Eduard
 
Share this answer
 
I dn't think you can't stop a transfer via web post, once it's started. If you were using FTP, that would be different.

To answer your question, merely add button-click handlers to your aspx page/code-behind.
 
Share this answer
 
ConfirmButtonExtender will be a quick solution here.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900