本文介绍了从后端代码显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 嗨朋友们, 我需要显示来自后端代码的图片。 这里我的代码: 开关(sExtension) { case docx: SLogo = ../ assets /图像/活动/ word_logo.jpg; break ; case doc : SLogo = ../ assets / images / Events / word_logo.jpg; break ; case ppt : SLogo = ../ assets / images / Events / ppt_logo; break ; case jpg : SLogo = ../ assets / images / Events / jpg_logo; break ; case pdf : SLogo = ../ assets / images / Events / pdf_logo; break ; } < img id = logo_img src = alt = / > 但是在 Evets.aspx.cs ,我无法访问此图像控件。 我需要访问它, logo_img.src = sLogo; 解决方案 使用Asp.Net 图片 [ ^ ]控制。 < asp:Image ID = logo_img runat = server AlternateText = SomeAlternateTextForImage > < / asp:图片 > 现在在aspx.cs页面中进行如下操作。 logo_img.ImageUrl = sLogo; Hi friends,I need to display image from back-end code.Here my code:switch (sExtension){ case "docx": SLogo = "../assets/images/Events/word_logo.jpg"; break; case "doc": SLogo = "../assets/images/Events/word_logo.jpg"; break; case "ppt": SLogo = "../assets/images/Events/ppt_logo"; break; case "jpg": SLogo = "../assets/images/Events/jpg_logo"; break; case "pdf": SLogo = "../assets/images/Events/pdf_logo"; break;}<img id="logo_img" src="" alt="" />But in Evets.aspx.cs, I can't access this image control.I need to access this as, logo_img.src = sLogo; 解决方案 Use Asp.Net Image[^] Control.<asp:Image ID="logo_img" runat="server" AlternateText="SomeAlternateTextForImage"></asp:Image>Now do like below in aspx.cs page.logo_img.ImageUrl = sLogo; 这篇关于从后端代码显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-24 10:32