在标签中查看fileupload控制文件的文件名 [英] see the file name of fileupload contol in a label

查看:157
本文介绍了在标签中查看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;
             }

推荐答案



我添加了一个FileUpload,lable和button control in aspx页面。下面按钮点击实现的代码,按预期工作正常。



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





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



最好的问候

Muthuraja



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

Best Regards
Muthuraja


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

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