文件浏览在页面加载+ c#.net时清除 [英] file browse get cleared at the page load +c#.net

查看:93
本文介绍了文件浏览在页面加载+ c#.net时清除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

图片成功上传.页面加载后,文件浏览文本框中的文本被清除,这是真正的问题,需要我解决

这是我的代码

Picture uploaded sucessfully. after the page load the text in file browse text box cleared this is the real problem guide me to fix

This is my code

try
{
if (fileExt == ".jpg" || fileExt == ".gif" || fileExt == ".bmp" || fileExt == ".jpeg" || fileExt == ".png")
                   {
           file.SaveAs(Server.MapPath("~/Images/") + fileName);
                       if (i == 0)
                       {
                           Image1.ImageUrl = "~/Images/" + fileName;
                           string filePath = Server.MapPath("~/Images/").ToString();
                           file.SaveAs(Server.MapPath("~/Images/") + fileName);
                       }
                   }
               }
               catch (Exception ex)
               {
                   throw ex;
               }

推荐答案

亲爱的达蒙,

首先,这没有问题.一旦您上传图像并将其保存到目录中,则无需将该文本保留在控件中,否则当您再次单击上传时它将一次又一次地上传.解决方案.

是的,那里有一种选择.

您可以使用agax contol工具包.
并使用工具包中的Asyc文件上传控件..

使用此链接获取更多信息....

http://www.asp.net/ajaxlibrary/AjaxControlToolkitSampleSite/ [
Dear Tamimun,

first of all, it is not a problem.once you upload image and it is saved to your diectory, there is no need to keep that text in your control otherwise when you click upload again it will be uploaded again and again.There is no solution for that.

Yes one alternative is there.

You can use agax contol toolkit.
and use Asyc file upload control from toolkit..

use this link for more ....

http://www.asp.net/ajaxlibrary/AjaxControlToolkitSampleSite/[^]


这篇关于文件浏览在页面加载+ c#.net时清除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆