Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi all,

 

I am facing trouble with using Response.BinaryWrite.

 

 

Private Sub lnkCustomerData_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lnkCustomerData.Click
       Dim ds As DataSet
       Dim objService As New AMSInternalUserService.AMSInternalUserService
       Dim lngReportFileId As Long
       lngReportFileId = lstPrevUpload.SelectedItem.Value
       ds = objService.GetReportFileDetails(lngReportFileId)
       If ds.Tables(0).Rows.Count > 0 Then
           Dim strFileExt, strFileName As String
           strFileName = ds.Tables(0).Rows(0).Item("ReportCustomerFileName")
           If InStr(strFileName, ".") > 0 Then
               strFileExt = Mid(strFileName, InStr(strFileName, "."), Len(strFileName))
               Select Case LCase(strFileExt)
                   Case ".xls"
                       Response.ContentType = "application/x-msexcel"
                   Case ".doc"
                       Response.ContentType = "application/msword"
                   Case ".txt"
                       Response.ContentType = "text/plain"
                   Case ".ppt"
                       Response.ContentType = "application/vnd.ms-p"
                   Case ".pdf"
                       Response.ContentType = "application/pdf"
               End Select

               Response.AddHeader("content-disposition", "attachment; filename=" + ds.Tables(0).Rows(0).Item("ReportCustomerFileName"))
               If Not IsDBNull(ds.Tables(0).Rows(0)("ReportFileCustomer")) Then
                   Response.BinaryWrite(ds.Tables(0).Rows(0)("ReportFileCustomer"))
               End If
               Response.End()
           End If
       End If

 

This is the code I use to download a file on the Link Button click.

 

Now the trouble is that this link button is placed on a form which is invoked through

 

window.showModalDialogBox method.

 

While debugging there is no error and everything goes fine, each and every line of code is executed perfectly but the popup does not appear.

 

Any help is greatly appreciated.

 

 

Thanks

Ashutosh

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...