2009-12-01 104 views
1

对于以下情形:文件上传节目等待消息,同时回发excecuting

我有一个ASP.NET FileUpload控件和一个按钮,用于上传选择的文件回传。

我想知道,如果用JavaScript我可以:

  1. 开始显示的图像(加载图片)当有人点击该excecutes上传
  2. 停止显示图像按钮时的上传该文件是完整的

限制:我不能在这种情况下使用ajax。

回答

2

你可以做这样的事情。

<asp:FileUpload ID="FileUpload" runat="server" /> 
<asp:Button ID="btnUpload" runat="server" Text="Upload" OnClientClick="DisplayWaiting()"/> 
<asp:Image ID="Image1" runat="server" ImageUrl="~/Images/waiting.jpg" style="display:none;" /> 

<script language="javascript"> 
function DisplayWaiting() 
{ 
    var img = document.getElementById("Image1"); 
    img.style.display = 'block'; 
} 
</script> 

image标记的默认显示属性设置为无。当点击上传按钮时,调用DisplayWaiting()函数将显示属性切换为阻止,显示图像。在页面帖子返回之后,图像标签被呈现,其显示属性设置为无,隐藏图像。

0
<div id="divLoadingImgID" style="display:none;"><img src="path/to/loading/img.gif"/></div> 

function uploadNow(){ 
    document.getElementById ("divLoadingImgID").style.display = "inline"; 
    // I don't how you are uploading the file. Anyways write your code here. 
    // And then set document.getElementById ("divLoadingImgID").style.display = "block"; when your uploading is done. 
}