0/5 (7 avis)
Vue 7 971 fois - Téléchargée 249 fois
Imports System.ComponentModel Imports System.Web.UI Imports System.Web.UI.HtmlControls Imports System.Web.UI.WebControls Imports System.IO <DefaultProperty("Text"), _ ToolboxData("<{0}:Upload runat=server></{0}:Upload>"), _ Description("The description for this confirm button")> _ Public Class Upload Inherits System.Web.UI.WebControls.WebControl Implements INamingContainer Dim strDossierUpload As String Dim strIdForm As String Dim InputFile As New HtmlInputFile '/////////////////// ' Dossier d'upload '/////////////////// <Bindable(True), Category("Divers"), DefaultValue(""), Description("Dossier ou va être uploader le fichier")> _ Property DossierUpload() As String Get Return strDossierUpload End Get Set(ByVal Value As String) strDossierUpload = Value End Set End Property '************************ '/// Id Formulaire /// '************************ <Bindable(True), Category("Divers"), DefaultValue("Form2"), Description("Nom de l'ID du tag formulaire")> _ Property IdFormulaire() As String Get Return strIdForm End Get Set(ByVal Value As String) strIdForm = Value End Set End Property Private Sub btUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs) '********************************************** '/// Upload le fichier sur le server /// '********************************************** Dim cheminAppli As String = Page.Request.PhysicalPath Dim nomPage As String = Path.GetFileName(Page.Request.PhysicalPath) Dim lng As Integer = cheminAppli.Length - nomPage.Length cheminAppli = Left(cheminAppli, lng) cheminAppli &= strDossierUpload Dim fichier As String If Not (InputFile.PostedFile Is Nothing) Then Try Dim postedFile = InputFile.PostedFile Dim filename As String = Path.GetFileName(postedFile.FileName) Dim contentType As String = postedFile.ContentType Dim contentLength As Integer = postedFile.ContentLength fichier = cheminAppli & "\" & filename postedFile.SaveAs(fichier) Catch exc As Exception 'LbErreur.Text = "Upload non réaliser" End Try End If End Sub 'créer les sous controls Protected Overrides Sub CreateChildControls() Controls.Clear() 'Init btUpload Dim btUpload As New HtmlInputButton("button") btUpload.ID = "btUpload" btUpload.Value = "btUpload" 'Upload btUpload.Value = "btUpload" 'Upload AddHandler btUpload.ServerClick, AddressOf btUpload_Click Controls.Add(btUpload) 'Init InputFile InputFile.ID = "uploadedFile" InputFile.EnableViewState = True InputFile.Name = "uploadedFile" Controls.Add(InputFile) End Sub End Class
2 mai 2005 à 14:00
2 mai 2005 à 13:52
2 mai 2005 à 12:16
La partie FORUM (qui est fort bien faite d'ailleurs, merci NIX) est la pour ca !!!
A bon entendeur ... Mais je teste ca des que possible
Le code a l'air clair en tout cas
2 mai 2005 à 11:54
2 mai 2005 à 09:53
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.