我的 MultiView 的第二个视图中有一个 AjaxFileUpload 控件。默认情况下,MultiView 的第一个视图出现,通过单击一个按钮,我到达具有 AjaxFileUpload 控件的第二个视图。此控件不上传任何文件,上传一直停留在 93% 或 99% 或 100%。
但是当我将第二个视图设置为默认视图时,AjaxFileUpload 控件可以正常工作。
WebForm 中的代码(aspx 页面):
<asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0">
<asp:View ID="View1" runat="server">
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
</asp:View>
<asp:View ID="View2" runat="server">
<asp:AjaxFileUpload ID="AjaxFileUpload1" runat="server" onunload="AjaxFileUpload1_Unload"
onuploadcomplete="UploadComplete" ThrobberID="myThrobber" onload="AjaxFileUpload1_Load"
oninit="AjaxFileUpload1_Init" />
<asp:AnimationExtender ID="AjaxFileUpload1_AnimationExtender" runat="server" Enabled="True"
TargetControlID="AjaxFileUpload1">
</asp:AnimationExtender>
<asp:Button ID="Button1" runat="server" Text="Button" />
</asp:View>
</asp:MultiView>
cs页面中的代码(aspx.cs):
protected void Page_Load(object sender, EventArgs e)
{
}
protected void UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
{
string path = Path.GetTempPath();
AjaxFileUpload1.SaveAs(Server.MapPath("files/")+ e.FileName);
}
protected void AjaxFileUpload1_Unload(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 1;
}
我做错了什么,我该如何解决这个问题?