mysql - 如何显示数据库获取的链接中的图像

标签 mysql asp.net

我正在使用带有 mysql 数据库的 Web 表单开发一个 ASP.NET Web 应用程序。在我的应用程序中,我已将图像存储在文件夹中,并且该图像的链接存储在数据库中 我想通过从数据库中获取这些链接来显示这些图像 我尝试了以下代码来显示图像

home.aspx.cs

     protected void Page_Load(object sender, EventArgs e)
    {    
       profile_picture = (string)(Session["link"]); //link has been taken from db
    }

home.aspx

<asp:Image runat="server" ID="profile_picture" ImageUrl="Label"></asp:Image>

错误是 =>错误 4 无法将类型“string”隐式转换为“System.Web.UI.WebControls.Image” 怎么解决这个问题? 谢谢。

最佳答案

profile_picture.ImageUrl = (string)(Session["link"]);

这应该有帮助。不确定 ImageUrl 是否是正确的属性,但请查看 System.Web.UI.WebControls.Image(即“profile_picture”的 typeOf),并查看图像链接应设置为哪个属性。

关于mysql - 如何显示数据库获取的链接中的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33172864/

相关文章:

c# - 数据未从 View (ajax)发送到 Controller (c#)

c# - 找到与名为 'Home' 的 Controller 匹配的多个类型。 (奇怪的错误)

php - Symfony Doctrine i18n 行为数据加载失败 : Integrity constraint violation

mysql - 在 kubernetes 中运行多个 mysql pod

c# - Telerik Radcombobox autopostback 根本不触发

asp.net - View 状态压缩问题

c# - GridView 中的文本框

php num_rows 不工作

mysql - 无法设置与 MySQL 工作台的连接

python - mysqldump 的奇怪十六进制字符行为