I am using an AJAX Toolkit AsyncFileUpload as follows...
<p>
<asp:Label runat="server" Text="Choose a webstock file to upload..." ID="uploadResult" />
<asp:Button ID="btnImport" Text="Import Data to Website »" OnClick="importData" runat="server" Visible="false" />
</p>
<asp:AsyncFileUpload ID="afuStockImport" runat="server"
OnUploadedComplete="uploadComplete"
OnClientUploadError="uploadError"
OnClientUploadStarted="StartUpload"
OnClientUploadComplete="UploadComplete"
Width="400px"
UploaderStyle="modern"
UploadingBackColor="#b9b9b9"
CompleteBackColor="#00FF00"
ErrorBackColor="#FF0000"
ThrobberID="myThrobber"
ClientIDMode="AutoID"/>
<asp:Label runat="server" ID="myThrobber" style="display:none;" >
<img align="absmiddle" alt="" src="adminimages/uploading.gif" />
</asp:Label>
I am trying to access the btnImport control to make it visible on success of upload, but accessing it from the uploadComplete procedure in the code behind does nothing....
protected void uploadComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
{
try
{
//upload file to web file system
System.Threading.Thread.Sleep(5000);
if (afuStockImport.HasFile)
{
string strPath = Server.MapPath("~/admin/stockfiles/") + Path.GetFileName(a开发者_JAVA技巧fuStockImport.PostedFile.FileName);
afuStockImport.SaveAs(strPath);
btnImport.Visible = true;
}
}
catch (Exception ulEx)
{
//Error message
}
}
Any help would be appreciated.
Cheers, Ben
Actually you can access that button but your changes don't applied as the uploadComplete method executed asynchronously. in my opinion its better to hide the btnImport using style="display: none;", handle client-side OnClientUploadComplete event of the AsyncFileUpload and show button after file was uploaded successfully.
精彩评论