有时刷新有时不刷新?这是神马情况?

hebaobao19880921 2011-07-27 11:28:31

private void FN_UpFiles()
{
//遍历File表单元素
HttpFileCollection files = HttpContext.Current.Request.Files;
try
{
for (int iFile = 0; iFile < files.Count; iFile++)
{
//检查文件扩展名字
HttpPostedFile postedFile = files[iFile];
string fileName = "";
fileName = Path.GetFileName(postedFile.FileName);
if (fileName != "")
{
try
{
string strpath = System.Web.HttpContext.Current.Request.MapPath("~/ResourcesFolder/") + fileName;
if (System.IO.File.Exists(strpath))
{
Response.Write("已经存在文件:" + fileName + "<br>");
}
else
{
try
{
NRModel.File model = new NRModel.File();
NRBLL.File bf = new NRBLL.File();
Guid guid1 = Guid.NewGuid();
Guid guid2 = Guid.NewGuid();
Guid guid3 = Guid.NewGuid();
Guid guid4 = Guid.NewGuid();
model.Fileid = guid1;
model.Folderid = guid2;
model.Filepath = strpath;
model.FileNam = fileName.ToString();
model.FileSize = postedFile.ContentLength;
model.Decription = this.decrition.Value;
model.CreateOn = DateTime.Now;
model.CreateBy = guid3;
model.ModefyBy = guid4;
if (bf.FN_AddNewRes(model) > 0)
{
postedFile.SaveAs(System.Web.HttpContext.Current.Request.MapPath("~/ResourcesFolder/") + fileName);
Page.RegisterStartupScript("提示", "<script language='javascript'>alert('上传成功!')</script>");
//Response.Write("<script language='javascript'>window.close();</script>");
//Response.Write("<script language='javascript'>self.opener.location.reload();</script>");

}
else
{
Page.RegisterStartupScript("提示", "<script language='javascript'>alert('上传失败!')</script>");
}

}
catch (Exception ex)
{

Response.Write(ex.ToString());
}

}

}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
}
}
}
catch (System.Exception ex)
{
Response.Write(ex.ToString());
}
}


这是我一段上传文件的函数.
当我的文件上传完毕 当前页面关闭 刷新父页面 可是总是有时刷新 有时不刷新 有什么办法可以必刷呢?
...全文
50 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
游戏人间 2011-07-27
  • 打赏
  • 举报
回复
Response.Write("<script language='javascript'>window.close();</script>");
Response.Write("<script language='javascript'>self.opener.location.reload();</script>");

调换一位置看看。
Response.Write("<script language='javascript'>self.opener.location.reload();</script>");
Response.Write("<script language='javascript'>window.close();</script>");
hebaobao19880921 2011-07-27
  • 打赏
  • 举报
回复
顶一下自己

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧