Click here to Skip to main content
13,201,050 members (52,095 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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 7-Feb-13 23:17pm

1 solution

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

Solution 1

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

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.171020.1 | Last Updated 8 Feb 2013
Copyright © CodeProject, 1999-2017
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