Bonjour,

Ma problematique est dans le titre...
En gros j'ai une fenetre asp sur laquelle j'ai des cases à cocher, qd je valide je veux que les documents créés en fonction des cases cochées soit téléchargé, et donc qu'il y ai autant de fenetre de téléchargement que de cases cochées.
Ca marche bien pour une case cochée, mais des que j'ai plusieurs case cochée, ca fait n'importe quoi.
Ce qui est normal, vu que pour afficher la fentre de telechargment je mets "response.end", et le code derriere ne s'execute pas...
je vous mets le code que j'ai fais.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
    Private Sub BtnOK_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnOK.Click
        Dim Lfichier As String = ""
 
If FicheVersement.Checked Then 'And HttpContext.Current.Session("FicheVersementOK") <> "true" Then
            Lfichier = ReplaceCustomXml(My.Resources.Fiche1, "Fiche1")
            DownloadOpenFile(Lfichier)
 
        End If
        If TabAmort.Checked Then
            ' Lfichier = ReplaceCustomXml(My.Resources.Fiche2,"Fiche2")
            ' DownloadOpenFile(Lfichier)
        End If
        If Attestation.Checked Then
            Lfichier = ReplaceCustomXml(My.Resources.Fiche3, "Fiche3")
            DownloadOpenFile(Lfichier)
        End If
        If EnvoiDoc.Checked Then
            Lfichier = ReplaceCustomXml(My.Resources.Fiche4, "Fiche4")
            DownloadOpenFile(Lfichier)
        End If
        If RetourDoc.Checked Then
            Lfichier = ReplaceCustomXml(My.Resources.Fiche5, "Fiche5")
            DownloadOpenFile(Lfichier)
        End If
        If Caution.Checked Then
            Lfichier = ReplaceCustomXml(My.Resources.Fiche6, "Fiche6")
            DownloadOpenFile(Lfichier)
        End If
        If Signature.Checked Then
            Lfichier = ReplaceCustomXml(My.Resources.Fiche7, "Fiche7")
            DownloadOpenFile(Lfichier)
        End If
        Response.End()
end sub
 
 Public Sub DownloadOpenFile(ByVal Lfichier As String)
        Dim stream As FileStream = File.Open(Lfichier, FileMode.Open)
        Dim filename As String = Path.GetFileName(Lfichier)
        'Dim extension As String = Path.GetExtension(Lfichier)
        'Response.ClearHeaders()
        'Response.ClearContent()
        Response.ContentEncoding = System.Text.Encoding.UTF8
        Context.Response.ContentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
        Context.Response.AddHeader("Content-disposition", "attachment; filename= " & filename)
 
          Try
            Dim buffer(stream.Length) As Byte ' = New Byte(4056) 
            Dim bytesRead As Integer = 0 'buffer.Length
            bytesRead = stream.Read(buffer, 0, buffer.Length)
            While (bytesRead > 0)
                Response.OutputStream.Write(buffer, 0, bytesRead)
                bytesRead = stream.Read(buffer, 0, buffer.Length)
            End While
        Catch ex As Exception
            CMsgAlerte.Show(ex.Message)
        Finally
            stream.Close()
            Response.OutputStream.Flush()
            Response.OutputStream.Close()
        End Try
 
    End Sub
J'espere avoir ete assez clair, n'hésitez pas me demander de plus amples précisions.
merci pour vos lumieres!!