Can't get AsyncFileUpload to work in update panel

后端 未结 4 1029
广开言路
广开言路 2020-12-06 13:53

I have a user control with a updatepanel, script manager and a asyncfileupload control.

<%@ Register Assembly=\"AjaxControlToolkit\" Namespace=\"AjaxContr         


        
4条回答
  •  不知归路
    2020-12-06 14:34

    Make sure that the usercontrol with asyncfileupload control is not loaded asynchronously, for example via Response.Redirect("pageWithUploadControl").

    Have you handled the FileUploadComplete Event and checked if AsyncFileUploadState is Success?

       Private Sub AsyncFileUpload1_UploadedComplete(ByVal sender As Object, ByVal e As AjaxControlToolkit.AsyncFileUploadEventArgs) Handles AsyncFileUpload1.UploadedComplete
            If e.state = AjaxControlToolkit.AsyncFileUploadState.Success Then
                '....'
            Else
                showErrorMessage(e)
            End If
        End Sub
    
        Private Sub showErrorMessage(ByVal e As AjaxControlToolkit.AsyncFileUploadEventArgs)
            Dim message As String = String.Empty
            Select Case e.statusMessage
                Case AjaxControlToolkit.AsyncFileUpload.Constants.Errors.EmptyContentLength
                    message = "Empty content length!"
                Case AjaxControlToolkit.AsyncFileUpload.Constants.Errors.FileNull
                    message = "Fill NULL!"
                Case AjaxControlToolkit.AsyncFileUpload.Constants.Errors.InputStreamNull
                    message = "Input Stream NULL!"
                Case AjaxControlToolkit.AsyncFileUpload.Constants.Errors.NoFileName
                    message = "No File Name!"
                Case AjaxControlToolkit.AsyncFileUpload.Constants.Errors.NoFiles
                    message = "No Files!"
            End Select
            LblMessage.Text = message 
        End Sub
    

    Try to change change the enctype of your form:

提交回复
热议问题