在标签中查看fileupload控制文件的文件名

在标签中查看fileupload控制文件的文件名

本文介绍了在标签中查看fileupload控制文件的文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

heyy ..我有一个文件上传控件....我想要的是,我需要通过文件上传控件选择的文件的文件名...并且文件名显示在标签中... 。(当我通过文件上传控件选择时)....



这里找到了一个代码..但是当选择另一个文件名时它不会改变.. 。







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;
             }

推荐答案

protected void Button1_Click(object sender, EventArgs e)
    {
        Label1.Text = FileUpload1.FileName;
    }





使用fileupload控件的FileName属性,无论你想要什么。



最好的问候

Muthuraja



Use the FileName property of the fileupload control, where ever you want.

Best Regards
Muthuraja


这篇关于在标签中查看fileupload控制文件的文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 08:46