无法获取AsyncFileUpload在更新面板工作 [英] Can't get AsyncFileUpload to work in update panel
问题描述
我有一个UpdatePanel中,脚本管理和控制asyncfileupload用户控件。
I have a user control with a updatepanel, script manager and a asyncfileupload control.
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:ScriptManager ID="ScriptManager2" runat="server" ></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<cc1:AsyncFileUpload ID="AsyncFileUpload2" runat="server" />
<asp:LinkButton id="lbSubmitOrder" runat="server" title="Submit Order Request" class="btn_blue_dynamic_med"/>
</ContentTemplate>
</asp:UpdatePanel>
在我的code背后:
Dim path As String = Server.MapPath("~/temp/test.tmp")
AsyncFileUpload2.SaveAs(path)
在我AsyncFileUpload2对象中的文件名是什么。我似乎无法得到refernce到应该是上传的文件。
In my AsyncFileUpload2 object the filename is nothing. I can't seem to get a refernce to the file that is supposed to be uploaded.
-Nate
更新结果
我已经添加了
UPDATE
I've added
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
我不能在if语句创下了破发点,我选择一个文件之后。我想有什么不对我的网页上使用Ajax如何工作?不知道它是什么,但。
I can't hit a break point at the "if" statement after I choose a file. I guess there is something wrong on my page with how ajax is working? Not sure what it is though.
修复!结果
我是用一个可见=真/假格通过一个单选按钮显示了ajax上传框。答案告诉我,控件在那里加载页面。我带走了DIV和一切工作!我现在做节目/ jQuery的通过隐藏(我应该在第一时间做了)。
FIXED!
I was displaying the ajax upload box via a radio button with a visible=true/false div. The answer told me that the control has to be there the page loads. I took away the div and everything worked! I will now do the show/hide through jquery (which I should have done in the first place).
推荐答案
确认与asyncfileupload控制用户控件不通过的Response.Redirect(pageWithUploadControl)。
Make sure that the usercontrol with asyncfileupload control is not loaded asynchronously, for example via Response.Redirect("pageWithUploadControl").
你有没有处理的FileUploadComplete事件,并检查是否AsyncFileUploadState是成功?
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
尝试改变改变表单的ENCTYPE:
Try to change change the enctype of your form:
<form id="form1" enctype="multipart/form-data" runat="server">
这篇关于无法获取AsyncFileUpload在更新面板工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!