Bonjour,
Je souhaite ajouter une barre de progression mais ce contrôle n'existe apparemment pas en ASP.Net
Voila le code de mon contrôle :
et le code-behind associé :
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 <%@ Control Language="C#" AutoEventWireup="true" CodeFile="PopupFileUploader.ascx.cs" Inherits="PopupFileUploader" %> <asp:Panel ID="Panel_popup_AjoutDocument" runat="server" CssClass="panel_button_ajoutdocument" style="display:none"> <asp:Label ID="titre_popup_ajoutdocument" runat="server" CssClass="titre_popup_ajoutdocument" Text="<%$ Resources:ResourceEC, AjoutDocument %>"></asp:Label> <br /> <br /> <ajaxToolkit:AsyncFileUpload runat="server" ID="FU_AjoutDocument" CssClass="fu_ajoutdocument" CompleteBackColor="White" OnUploadedComplete="AjoutDocument_Click" ErrorBackColor="Red" UploadingBackColor="Cyan" OnClientUploadStarted="function(){uploadStarted('ctl00_Main_fileUploader_CancelButton');}" OnClientUploadError="function(){uploadFinished('ctl00_Main_fileUploader_CancelButton');}" OnClientUploadComplete="function(){uploadFinished('ctl00_Main_fileUploader_CancelButton');}"/> <asp:Label ID="limite_upload" runat="server" CssClass="limite_upload" Text="<%$ Resources:ResourceEC, LimiteUpload %>" /> <br /> <br /> <br /> <asp:Panel ID="Panel_button" runat="server" CssClass="Panel_button"> <asp:LinkButton ID="CancelButton" runat="server" CssClass="sexybutton sexyblue"> <span><span> <asp:Literal ID="Literal1" runat="server" Text="<%$ Resources:ResourceEC, Retour %>" /> </span></span> </asp:LinkButton> <asp:LinkButton ID="UploadButton" runat="server" CssClass="sexybutton sexyblue"> <span><span> <asp:Literal ID="Literal2" runat="server" Text="<%$ Resources:ResourceEC, Ajouter %>" /> </span></span> </asp:LinkButton> </asp:Panel> </asp:Panel> <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtenderAvertissement" runat="server" BehaviorID="Panel_popup_AjoutDocument" TargetControlID="titre_popup_ajoutdocument" PopupControlID="Panel_popup_AjoutDocument" BackgroundCssClass="modalBackground" CancelControlID="CancelButton"> </ajaxToolkit:ModalPopupExtender>
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 public partial class PopupFileUploader : System.Web.UI.UserControl { private Contact current; private bool uploaded; public bool Uploaded { get { return uploaded; } } protected void AjoutDocument_Click(object sender, EventArgs e) { AjouterDocument(); } public void AjouterDocument() { uploaded = false; if (FU_AjoutDocument.HasFile) { string locate = ConfigurationManager.AppSettings["document_client"]; current = (Contact)Session["Contact"]; foreach (Client cli in current.Clients) { string SavePath = string.Format(locate , cli.CodeClient); int fileSize = FU_AjoutDocument.PostedFile.ContentLength; if (fileSize < 5000000) { if (Directory.Exists(SavePath)) { FU_AjoutDocument.SaveAs(SavePath + @"\" + FU_AjoutDocument.FileName.Replace(" ", "_")); } else { Directory.CreateDirectory(SavePath); FU_AjoutDocument.SaveAs(SavePath + @"\" + FU_AjoutDocument.FileName.Replace(" ", "_")); } } else { return; } } uploaded = true; CallUploadEndedHandler(); } return; } /// <summary> /// Avertit l'ensemble des écouteurs abonnés à cet évenement /// </summary> private void CallUploadEndedHandler() { UploadEnded.Invoke(this, EventArgs.Empty); } public event EventHandler UploadEnded; }
Partager