ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,417 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I need to download the files using webforms with only one button click but only the first file are downloaded.
How can i do it?
See my code vb code.
StrSql = "Select * from TblOS_Anexo"
StrSql = StrSql & " WHERE TblOS_Anexo.IdOS = " & Me.IdOS.Text
StrSql = StrSql & " ORDER By TblOS_Anexo.Seq_Anexo "
Try
Dim TblOS_Anexo As SqlClient.SqlDataReader = Classes.Class_CriaData_SqlServer.CriaDataReader(Application("Bd_ConnectionString"), StrSql)
If TblOS_Anexo.HasRows Then
Do While TblOS_Anexo.Read
Anexo = TblOS_Anexo("Anexo")
StrPath = MapPath("~/Anexo_OS/") & Anexo
TblOS_Anexo("Anexo"))
If File.Exists(StrPath) Then
Response.Clear()
Response.ClearContent()
Response.ClearHeaders()
Response.AddHeader("Content-Disposition", "attachment;filename=""" & Anexo & """")
Response.TransmitFile(Server.MapPath("~/Anexo_OS/" + Anexo))
Response.Flush()
Context.ApplicationInstance.CompleteRequest()
Response.Close()
End If
Loop
Msg.ShowMessage("Download concluded!!!")
Else
Msg.ShowMessage("Don't have attachment to download!!!")
End If
Catch ex As Exception
Msg.ShowMessage("Error to download the file: " & ex.Message)
End Try
A http request (like file download) can only return one response. Your only option is to zip files into one download file.