fileupload在asp.net中不起作用 [英] fileupload is not working in asp.net

查看:102
本文介绍了fileupload在asp.net中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿伙计们,我认为我的visual studio 2013有问题。我的fileupload没有提供任何文件名,每次提供一个空值,以前它运行正常并上传文件但现在它不工作



代码/////



i在asp.net网页上创建fileupload,并在测试fileupload是否获得值。



 <   asp:按钮    ID   =  Button4    runat   =  server    OnClick   =  Button4_Click   文本  = 按钮    /  >  
< asp:FileUpload ID = FileUpload3 runat = server / >







 受保护  void  Button4_Click( object <> span  sender,EventArgs e)
{
string fname = ,fn = ;
fname = FileUpload3.FileName;

}




上述简单代码变量'fname'中的
获得空值总是来自fileupload。

有什么问题?我的视觉工作室有问题吗?

解决方案

如果您使用Updatepanel,请在updatepanel下复制此代码:

< Triggers>

< asp:PostBackTrigger ControlID =Button4/>

< /触发器>


如果你有一个可能性使用更新面板然后fileupload将变为null。

如果不是,那么

尝试使用FileUpload1.PostedFile.FileName;


hey guys i think there is something wrong with my visual studio 2013. my fileupload is not provide any filename ,every time it is giving a null value , previously it was running correctly and upload a file too but now it is not working

code/////

i have create fileupload in asp.net webpage and a button to test that whether fileupload get a value or not.

<asp:Button ID="Button4" runat="server" OnClick="Button4_Click" Text="Button" />
                            <asp:FileUpload ID="FileUpload3" runat="server" />




protected void Button4_Click(object sender, EventArgs e)
   {
       string fname = "", fn = "";
       fname = FileUpload3.FileName;

   }



in the above simple code variable 'fname' is getting a null value always from fileupload.
what is the problem ? is this a problem with my visual studio?

解决方案

If you use Updatepanel then copy this code under updatepanel:
<Triggers>
<asp:PostBackTrigger ControlID="Button4" />
</Triggers>


one posibility is that if you used update panel then fileupload will be become null.
if its not ,then
try to use FileUpload1.PostedFile.FileName;


这篇关于fileupload在asp.net中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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