Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET jQuery
heyy..I have a file upload control....All I wanted is, I need the file name of the file that I select through file upload controls..and that file name is displayed in a label....(when I selected through the file upload controls)....
 
here found a code ..but it is not changed when another file name is selected ...
 

 
if (Session["fluNoticeUpload"] == null && fluNoticeUpload.HasFile)
             {
                 Session["fluNoticeUpload"] = fluNoticeUpload;
                 lblfile.Text = fluNoticeUpload.FileName;
             }
             // Next time submit and Session has values but FileUpload is Blank
             // Return the values from session to FileUpload
             else if (Session["fluNoticeUpload"] != null && (!fluNoticeUpload.HasFile))
             {
                 fluNoticeUpload = (FileUpload)Session["fluNoticeUpload"];
                 lblfile.Text = fluNoticeUpload.FileName;
             }
             // Now there could be another sictution when Session has File but user want to change the file
             // In this case we have to change the file in session object
             else if (fluNoticeUpload.HasFile)
             {
                 Session["fluNoticeUpload"] = fluNoticeUpload;
                 lblfile.Text = fluNoticeUpload.FileName;
             }
Posted 8-Feb-13 0:17am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi,
I have added a FileUpload, lable and button control in the aspx page. Below code implemented in the button click and things are working fine as you expected.
 
protected void Button1_Click(object sender, EventArgs e)
    {
        Label1.Text = FileUpload1.FileName;
    }
 
Use the FileName property of the fileupload control, where ever you want.
 
Best Regards
Muthuraja
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 270
1 Sergey Alexandrovich Kryukov 185
2 BillWoodruff 173
3 CPallini 155
4 Kamal Rocks 144
0 OriginalGriff 5,655
1 DamithSL 4,506
2 Maciej Los 3,997
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,180


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 8 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100