catch IE download window event
When the user clicks the download button in my aspx page, the file (pdf)
downloaded from my server another drive. Once he clicks the button, I
inserted the record (count) on one of the table. After that the IE will ask do you want to save or cancel, the user may click cancel button.
so in this situtation, i need to insert the record on table once the user click save button. if the user clicks the cancel button, I should not insert the records. how to catch that event. any idea?
and also i have the file name like "file, user.pdf". when using Firefox, its
just display the "file," on downloading window.
is it any chance to resolve these issues?
below is the code i am using for downloading the file.
thanks
bala
Private Sub DownloadFile(ByVal fname As String, ByVal forceDownload As
Boolean)
Dim path1 As String = fname
Dim name As String = Path.GetFileName(path1)
Dim ext As String = Path.GetExtension(path1)
'Dim type As String = "Application/pdf"
Response.ContentType = "Application/pdf"
If forceDownload Then
Response.AppendHeader("content-disposition", "attachment;
filename=" & name)
Else
Response.AppendHeader("content-disposition", "inline;
filename=" & name)
End If
Dim MyFileStream As FileStream
Dim FileSize As Long
MyFileStream = New FileStream(fname, FileMode.Open)
FileSize = MyFileStream.Length
Dim Buffer(CInt(FileSize)) As Byte
MyFileStream.Read(Buffer, 0, CInt(FileSize))
MyFileStream.Close()
Response.BinaryWrite(Buffer)
Response.End()
End Sub

