I have an ASPX 4.0 page (with Async="true") that contains a user control with a Telerik RadGrid. Each row contains a button that causes an AJAX postback when clicked. When the user clicks the button I am trying to copy a PDF file from one server to this one. This works but the page is waiting until the entire file is completed before the postback completes. I am only wanting to "kickoff" the file copy when the user clicks the button then allow them to continue doing other things without having to wait for the large files to complete copying. I would have figured that doing this asynchronously would have worked but the AJAX panel is still waiting for the operation to complete.
Here is the relevant code that gets called when the user clicks the button:
Public Sub GetPDF(ByVal newFileLocationAndName As String, ByVal origFileLocationAndName As String)
Dim myWebClient As WebClient = New WebClient
AddHandler myWebClient.DownloadFileCompleted, AddressOf WebClient_DownloadFileCompleted
myWebClient.DownloadFileAsync(New Uri(newFileLocationAndName), origFileLocationAndName)
End Sub
Private Sub WebClient_DownloadFileCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs)
Dim wc As WebClient = DirectCast(sender, WebClient)
RemoveHandler wc.DownloadFileCompleted, AddressOf WebClient_DownloadFileCompleted
wc.Dispose()
End Sub
Also its a bit confusing as your are throwing this all into mix - telerik/ajax panels/ and async code, seems like you are trying to knock in a pin with a 8 pound hammer...