母版页表单标签:
<form runat="server" enctype="multipart/form-data" method="post">
文件上传.aspx
<asp:UpdatePanel runat="server" ID="upnlFileUpload">
<ContentTemplate>
<asp:Button ID="Save" runat="server" Text="Save"
style="margin-left: 0px" Width="350px" onclick="Save_Click" />
<ajaxToolkit:AsyncFileUpload
ID="AsyncFileUpload1" runat="server"
onuploadedcomplete="AsyncFileUpload1_UploadedComplete" />
</ContentTemplate>
</asp:UpdatePanel>
文件上传.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
btnSave.Enabled = false;
}
}
protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
{
btnSave.Enabled = true;
}
如果我上传文件,则 UploadedComplete 会被触发(我通过将文件保存在临时位置来测试它),但“保存”按钮未启用。甚至断点也能下线:
btnSave.Enabled = true;
这段代码有什么问题?!