我可以从数据库设置图像路径吗? [英] Can I Set Image Path From Database?

查看:71
本文介绍了我可以从数据库设置图像路径吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在asp.net C#图像中的img标签中给出src在一个名为images的文件夹中的图像

谢谢!

解决方案

我会使用ASP.NET Image控件

< asp:image id =   Image1 runat =   server /> 



您可以在CodeBehind中设置ImageUrl属性,如下所示:

  //   string DbimageFileNameWithExtention =image.jpg;  
Image1.ImageUrl = Image1.ResolveUrl( string .Format( 〜/ images / {0},DbimageFileNameWithExtention) ;





 Image1.ImageUrl =  〜/ images / + DbimageFileNameWithExten灰; 


how to give src in img tag from database in asp.net C# images in a folder named images
Thanks !

解决方案

I would use ASP.NET Image control

<asp:image id="Image1" runat="server" />


You can set the ImageUrl property in the CodeBehind as follows:

//string DbimageFileNameWithExtention ="image.jpg";
Image1.ImageUrl = Image1.ResolveUrl(string.Format("~/images/{0}", DbimageFileNameWithExtention);


Or

Image1.ImageUrl = "~/images/" +DbimageFileNameWithExtention;


这篇关于我可以从数据库设置图像路径吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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