• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 708
  • Last Modified:

File Download dialog events in ASP.NET

Hi Everyone,

I have been breaking my head over a problem from the past couple of days.
My problem is that I have to provide an option for the user to upload and download files to the server. I have already done this by providing the file upload control for uploading the file and later providing a link for all uploaded files in a gridview, clicking on which will download the file to client's local machine at the path of his choice. When the user clicks on the link he is prompted with a file download dialog after which he can choose to open or save the file or cancel the download.
What I am required to do is to set a flag in my database whenever a user downloads a file. To do this I need to find out which of the 3 buttons (Open, Save, Cancel) the user has clicked. Only if the user Opens/Saves the file, should I update the flag in the database. So is there any way either through javascript or ASP.NET that I can track such an event and update the flag.
0
Shashidhar_Shenoy
Asked:
Shashidhar_Shenoy
  • 3
2 Solutions
 
rajeeshmcaCommented:
HI,

 i dont think that can be done... That is client side browser event. Instead u can make an update in to the database while he clicks the Link for the download
0
 
Shashidhar_ShenoyAuthor Commented:
Thanks for the quick reply.

In fact that is exactly what I am doing now. But the user could cancel the download after clicking on the download link. That is why I am trying to look for the events (if any) of file download dialog.

Is there any alternate way in which I could achieve the same result?
0
 
sybeCommented:
Agree with rajeeshmca. You can not do that. At the moment the user clicks the link, the file is transferred to the client (to the browser cache). The dialogue only asks the user what to do with the file which is already (partly) in their own cache.

You should also realize that an HTTP-request is not necessarily done by a browser, or that every browser must have the same buttons.
0
 
Shashidhar_ShenoyAuthor Commented:
Thanks guys for the reply. After a lot of googling around even I have come to a conclusion that it is not possible to do that. Instead I have chose to warn the user by using a javascript confirm dialog saying that if he proceeds then the flag will be set in the database. If he clicks OK on the confirm dialog then after that even if he chooses to cancel the download later the flag will be set in the database.
0
 
Shashidhar_ShenoyAuthor Commented:
Although I did not get a solution to my actual problem I atleast came to know that what I was trying to achieve was not possible and that I had to look for another alternative. Thanks to both the experts for their quick replies.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now