Re: UploadCompleted Server-side Event Not Firing

  •  03-29-2010, 6:42 PM

    Re: UploadCompleted Server-side Event Not Firing

    Hi Eric,
     
    My upload code is part of a large web site.  I couldn't post it all here, but I'll try to paste the pertinent sections (hope this helps):
     

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    ShowUserInfo()
    InitializeUploadControl()
    ImportClientSideLibraries()

    If Not Page.IsPostBack Then
       Session("puUploadCount") = 0

    Else
    ShowOnScreenConfirmation() ' Displays some confirmation on screen

    End If

     

    End Sub
     
    Protected Sub InitializeUploadControl()
    Dim MaxFileSize As Int64 = ConfigurationManager.AppSettings("FileUploadMaxKBSize")
    Dim objSupportFuncs As New CloseoutPkgUploadSupport

    Me
    .Uploads.InsertText = "Browse File(s)"
    Me.BulletedList1.Items.Add("The maximum file size accepted is " & (MaxFileSize / 1024).ToString & "MB")Me.Uploads.ManualStartUpload = True
    Me.Uploads.CancelUploadMsg = "Clearing all files from the list ..."
    Me.Uploads.ShowFileIcons = True
    Me.Uploads.CancelAllMsg = "Clear File List"
    Me.Uploads.FileTooLargeMsg = "The file you're trying to upload is too large."
    Me.Uploads.FileTypeNotSupportMsg = "The file type you're attempting to upload is not allowed"
    Me.Uploads.ValidateOption.AllowedFileExtensions = objSupportFuncs.GetAllowedExtensions
    Me.Uploads.TempDirectory = "~/TempFileUploads"
    Me.Uploads.ValidateOption.MaxSizeKB = "50000"

    End Sub

    Protected Sub Uploads_FileValidating(ByVal sender As Object, ByVal args As CuteWebUI.UploaderEventArgs) Handles Uploads.FileValidating

    ' This is fired for each file being uploaed by the AJAX Uploader control
    Dim FileNameOnDisk As String
    Dim TargetDirectory As String
    Dim UploadSavedToDB As Integer
    Dim FundNo As String = Session("puFundInfo").FundNo
    Dim objSupportFuncs As New CloseoutPkgUploadSupport

    Try

    ' Construct file name as it will be stored on disk
    FileNameOnDisk = objSupportFuncs.BuildFileName(FundNo, args.FileName)

    ' Create the folder if it doesn't exist and get the folder path
    TargetDirectory = objSupportFuncs.CreateFolder(FundNo)

    ' Save file metadata to database. The value returned is the integer key of the DB entry.
    ' If 0 is returned, there was an error inserting into the DB
    UploadSavedToDB = objSupportFuncs.SaveUploadToDB(FileNameOnDisk, Session("UID"), FundNo, TargetDirectory, args.FileName, args.FileSize, "", "CloseoutPkg")

    ' Move file to final folder
    args.MoveTo(Replace(TargetDirectory, "\", "\\") & FileNameOnDisk)
    Session(
    "puUploadCount") += 1

    Catch ex As Exception
    ' To do. Handle exceptions

    End Try

     

    End Sub
     

    Protected Sub Uploads_UploadCompleted(ByVal sender As Object, ByVal args() As CuteWebUI.UploaderEventArgs) Handles Uploads.UploadCompleted

        NotifyUsers()  ' Sends e-mail

    End Sub

View Complete Thread