Salut à tous depuis quelques jours je galère pour trouver comment faire apparaitre la fameuse boite de dialogue qui propose soit d'exécuter, soit d'ouvrir un fichier que l'on veut télécharger...

Pour l'instant l'évènement de mon bouton me permet uniquement de télécharger le fichier que je sélectionne (dans un GridView), vers c:/.

voila mon code c# :
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
 
    // Bouton de téléchargement 
    protected void btTelecharger_Click(object sender, EventArgs e)
    {
        // Lancement d'un thread qui se chargera du téléchargement
        Thread thread = new Thread(new ThreadStart(Telecharger));
        thread.Start(); 
    }
 
    // Méthode de téléchargement
    public void Telecharger()
    {
        string reqSelectRacine, reqSelectDossierPrinc, reqSelectSousDossier, reqSelectIdSociete, reqSelectJourDate, reqSelectMoisDate, reqSelectAnneeDate;
        string racine, dossierPrinc, sousDossier, typeDocument, matricule, idSociete, jour, mois, annee;
        string dateDocument, chemin, nomFichier, message;
        SqlConnection connexion = new SqlConnection("Data Source=STQY-589\\SQLEXPRESS; Initial Catalog=DossierIndividuel;Integrated Security=True");
        List<string[]> list = new List<string[]>();
        int nbLigne = gvSalarie.Rows.Count;
        for (int i = 0; i < nbLigne; i++)
        {
            list.Add(new string[2]{gvSalarie.DataKeys[i]["matricule"].ToString(),
                                   gvSalarie.DataKeys[i]["typeDocument"].ToString()});
            if (((CheckBox)gvSalarie.Rows[i].FindControl("uneSelection")).Checked)
            {
                try
                {
                    if (connexion.State == ConnectionState.Closed)
                    {
                        connexion.Open();
                    }
                    reqSelectRacine = "SELECT racine " +
                                      "FROM CHEMIN, DOCUMENT " +
                                      "WHERE [matricule] = '" + gvSalarie.DataKeys[i]["matricule"].ToString() + "' " +
                                      "AND [typeDocument] = '" + gvSalarie.DataKeys[i]["typeDocument"].ToString() + "' " +
                                      "AND CHEMIN.idChemin = DOCUMENT.idChemin ";
                    reqSelectDossierPrinc = "SELECT dossierPrincipal " +
                                            "FROM CHEMIN, DOCUMENT " +
                                            "WHERE [matricule] = '" + gvSalarie.DataKeys[i]["matricule"].ToString() + "' " +
                                            "AND [typeDocument] = '" + gvSalarie.DataKeys[i]["typeDocument"].ToString() + "' " +
                                            "AND CHEMIN.idChemin = DOCUMENT.idChemin ";
                    reqSelectSousDossier = "SELECT sousDossier " +
                                           "FROM CHEMIN, DOCUMENT " +
                                           "WHERE [matricule] = '" + gvSalarie.DataKeys[i]["matricule"].ToString() + "' " +
                                           "AND [typeDocument] = '" + gvSalarie.DataKeys[i]["typeDocument"].ToString() + "' " +
                                           "AND CHEMIN.idChemin = DOCUMENT.idChemin ";
                    reqSelectIdSociete = "SELECT idSociete " +
                                         "FROM DOCUMENT " +
                                         "WHERE [matricule] = '" + gvSalarie.DataKeys[i]["matricule"].ToString() + "' " +
                                         "AND [typeDocument] = '" + gvSalarie.DataKeys[i]["typeDocument"].ToString() + "' ";
                    reqSelectJourDate = "SELECT DAY(dateDocument) " +
                                        "FROM DOCUMENT " +
                                        "WHERE [matricule] = '" + gvSalarie.DataKeys[i]["matricule"].ToString() + "' " +
                                        "AND [typeDocument] = '" + gvSalarie.DataKeys[i]["typeDocument"].ToString() + "' ";
                    reqSelectMoisDate = "SELECT MONTH(dateDocument) " +
                                        "FROM DOCUMENT " +
                                        "WHERE [matricule] = '" + gvSalarie.DataKeys[i]["matricule"].ToString() + "' " +
                                        "AND [typeDocument] = '" + gvSalarie.DataKeys[i]["typeDocument"].ToString() + "' ";
                    reqSelectAnneeDate = "SELECT YEAR(dateDocument) " +
                                         "FROM DOCUMENT " +
                                         "WHERE [matricule] = '" + gvSalarie.DataKeys[i]["matricule"].ToString() + "' " +
                                         "AND [typeDocument] = '" + gvSalarie.DataKeys[i]["typeDocument"].ToString() + "' ";
                    // Exécution des requêtes
                    SqlCommand cmdSelectRacine = new SqlCommand(reqSelectRacine, connexion);
                    SqlCommand cmdSelectDossierPrinc = new SqlCommand(reqSelectDossierPrinc, connexion);
                    SqlCommand cmdSelectSousDossier = new SqlCommand(reqSelectSousDossier, connexion);
                    SqlCommand cmdSelectIdSociete = new SqlCommand(reqSelectIdSociete, connexion);
                    SqlCommand cmdSelectJourDate = new SqlCommand(reqSelectJourDate, connexion);
                    SqlCommand cmdSelectMoisDate = new SqlCommand(reqSelectMoisDate, connexion);
                    SqlCommand cmdSelectAnneeDate = new SqlCommand(reqSelectAnneeDate, connexion);
 
                    racine = cmdSelectRacine.ExecuteScalar().ToString();
                    dossierPrinc = cmdSelectDossierPrinc.ExecuteScalar().ToString();
                    sousDossier = cmdSelectSousDossier.ExecuteScalar().ToString();
                    typeDocument = gvSalarie.DataKeys[i]["typeDocument"].ToString();
                    matricule = gvSalarie.DataKeys[i]["matricule"].ToString();
                    idSociete = cmdSelectIdSociete.ExecuteScalar().ToString();
                    jour = cmdSelectJourDate.ExecuteScalar().ToString();
                    mois = cmdSelectMoisDate.ExecuteScalar().ToString();
                    annee = cmdSelectAnneeDate.ExecuteScalar().ToString();
 
                    dateDocument = jour + "-" + mois + "-" + annee;
                    chemin = racine + "" + dossierPrinc + "" + sousDossier + "" + typeDocument + "" + matricule + "" + idSociete + "" + dateDocument + ".pdf";
                    nomFichier = typeDocument + "" + matricule + "" + idSociete + "" + dateDocument + ".pdf";
 
                    // Création d'un objet WebClient (c'est lui qui permet de télécharger un fichier)
                    WebClient wc = new WebClient();
                    // Lancement du téléchargement
                    wc.DownloadFile(chemin, "c:/" + nomFichier);
                    // Destruction de l'objet WebClient
                    wc.Dispose();
                    // Et un petit message pour dire que le téléchargement est terminé
                    message = "Téléchargement effectué vers c:/"; 
                    Outil.Message(message, this); 
                }
                catch (Exception ex)
                {
                    Response.Redirect(@"PageErreur.Aspx?Id=Problème lors du téléchargement", true);
                }
            }
        }
        if (list.Count > 0)
        {
            Session["ListeDocSalarie"] = list;
        }
        connexion.Close();
    }

et voici mon code asp.net (j'sais pas si c'est très utile mais bon) :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
 
            <td style="width: 3px">
                <asp:Button ID="btTelecharger" runat="server" OnClick="btTelecharger_Click" Text="Télécharger" />
            </td>
Merci à celui (ou celle) qui me sortira de là, et me mettra sur la voie...