UpdateProgress和FileUpload [英] UpdateProgress and FileUpload
本文介绍了UpdateProgress和FileUpload的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我面对这个问题已经有一段时间了.我无法通过fileupload控件正确使用updateprogress.我的设计页面代码是:
Hi,
I am facing this issue for quite some time. I am not able to use updateprogress properly with fileupload control. My design page code is :
<asp:ScriptManager ID="scriptMgr" runat="server" />
<asp:UpdateProgress runat="server" id="PageUpdateProgress">
<progresstemplate>
Loading...<img border="0" src="Images/loading.gif" alt="loading" style="z-index: 1100;" />
</progresstemplate>
<asp:UpdatePanel ID="updatePnl" runat="server" UpdateMode="Conditional" >
<contenttemplate>
<table cellpadding="0" cellspacing="0" width="800px" border="0" align="center" class="description">
<tr>
<td width="70%">
<asp:FileUpload Width="250px" CssClass="field" ID="fileUploadText" runat="server" />
</td>
</tr>
<tr class="alt">
<td valign="top" colspan="2">
<table width="100%" border="0" cellspacing="0" cellpadding="2">
<tr>
<td width="60%" align="right">
<asp:Button ID="btnSubmit" runat="server" Text="Submit"
CssClass="button" onclick="btnSubmit_Click" OnClientClick="ShowProgress();"/>
</td>
</tr>
</table>
</td>
</tr>
</table>
</contenttemplate>
<triggers>
<asp:PostBackTrigger ControlID="btnSubmit"/>
</triggers>
而我的.cs代码是:
and my .cs code is :
protected void btnSubmit_Click(object sender, EventArgs e)
{
string filePath = Server.MapPath("Input File/" + fileUploadText.FileName);
fileUploadText.PostedFile.SaveAs(filePath);
System.Threading.Thread.Sleep(5000);
}
上面的代码工作正常,但.gif图像不会旋转.当我删除触发器标签和fileUpload控件时,图像开始旋转.
The above code works fine but .gif image does not rotate. When I remove trigger tag and fileUpload control then the image starts rotating. What is the reason for this and how can i resolve?
推荐答案
好,问题是,当您上传文件时,上传是同步的(回发),因此整个页面在上传过程中会刷新.
我建议您将FileUpload加载到IFrame中,并从IFrame中进行回发.
Well, the problem is, while you are uploading the file the upload is synchronous (Postback) and hence the whole page is refreshed during the upload.
I would recommend you to load the FileUpload inside an IFrame and do the postback from within the IFrame.
将Fileupload放入iframe后,我看不到.gif图像旋转
After putting Fileupload inside iframe, i do not see the .gif image rotating
当触发器引发Postback事件时,刷新事件刷新了页面,因此没有显示更新进度.
为防止您的页面完全回发,请使用iframe或一些基于Ajax的上传控件,例如
ajaxuploader
希望对您有所帮助!!!!!!
Hi,
As your trigger is raising Postback event which refreshes your page , hence not showing up the update progress .
To prevent your page from complete postback use iframe or some ajax based upload control like
ajaxuploader
Hope this helps !!!!
这篇关于UpdateProgress和FileUpload的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文