我希望有人会回应。我有一个控件,它有一个更新面板(设置为条件更新),其中有一个 asyncfileupload 控件。控件起初工作正常,但如果我上传文件,然后导致其更新面板更新,则 asyncfileupload.UploadedFileError 将在没有它或 asyncFileUpload.UploadedComplete 被调用的情况下触发。这是我创建控件的方式:
Public Class FileUpload
Inherits ScriptControl
Implements INamingContainer, IPostBackEventHandler
Private WithEvents asyncFileUpload As AjaxControlToolkit.AsyncFileUpload
....
asyncFileUpload = New AjaxControlToolkit.AsyncFileUpload
With asyncFileUpload
.ClientIDMode = UI.ClientIDMode.AutoID
.UploadingBackColor = ColorTranslator.FromHtml(UploadingBackColor)
.CompleteBackColor = ColorTranslator.FromHtml(CompleteBackColor)
.UploaderStyle = AjaxControlToolkit.AsyncFileUpload.UploaderStyleEnum.Traditional
.ThrobberID = img.UniqueID
End With
'then the control gets added to a Panel.
'events:
Protected Sub fileUploadFailure(ByVal sender As Object, ByVal e As AjaxControlToolkit.AsyncFileUploadEventArgs) Handles asyncFileUpload.UploadedFileError
'do stuff
end Sub
Protected Sub SaveUploadedFile(ByVal sender As Object, ByVal e As AjaxControlToolkit.AsyncFileUploadEventArgs) Handles asyncFileUpload.UploadedComplete
'do stuff
End Sub
正如我所提到的,该控件在上传文件时工作正常。但是我在同一个控件中有一个链接按钮,允许用户下载上传的文件(导致控件的更新面板更新)。发生这种情况时,fileUploadFailure 事件会无缘无故地触发(因为没有进行上传)。谁能解释发生了什么以及如何防止这种情况?