Click here to Skip to main content
15,037,928 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.NET
<asp:Button ID="Button4" runat="server" OnClick="Button4_Click" Text="Button" />
                            <asp:FileUpload ID="FileUpload3" runat="server" />



C#
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?
Posted
Updated 17-Dec-14 18:12pm
v2

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;
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900