在服务器上显示文件的图像和文件名。 [英] Display a image and a filename of a file on the server.

查看:115
本文介绍了在服务器上显示文件的图像和文件名。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在服务器上有文件,我希望在网页上显示为Image后跟文件名。



图像将取决于文件类型,



我正在做的是



asp:



< asp:LinkBut​​ton ID =LinkBut​​ton1runat =serverVisible ='false>

< img runat =serverid =Image2/>

< / asp:LinkBut​​ton>





c#:



I have files on server which i want to display on a web page as Image followed by filename.

the Image will be dependent on the file type,

what I am doing is

asp:

<asp:LinkButton ID="LinkButton1" runat="server" Visible='false">
<img runat="server" id="Image2"/>
</asp:LinkButton>


c#:

if (fi.Extension == ".txt")
                   {
                       Image2.Src = @"~\Upload\x_icon.png";
                       LinkButton1.Text = fi.Name;
                       LinkButton1.Visible = true;
                   }
                   else if (fi.Extension == ".docx")
                   {
                       Image2.Src = @"~\Upload\Add.jpg";
                       LinkButton1.Text = fi.Name;
                       LinkButton1.Visible = true;
                   }





但在这里我只获得text propertu set。我没有看到图片。

请帮助



but here I only get text propertu set. I do not see a Image.
Please help

推荐答案

< asp:LinkBut​​ton ID =LinkBut​​ton1runat =server> ;

< img runat =serverid =Image2/>

< / asp:LinkBut​​ton>





试试这个你的可见性是假的。如果Visible Propert为false,您如何看到图像。
<asp:LinkButton ID="LinkButton1" runat="server">
<img runat="server" id="Image2"/>
</asp:LinkButton>


TRy this you had put visbility false. How can you see an image if Visible Propert is false.


这篇关于在服务器上显示文件的图像和文件名。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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