在图像控件中显示默认图像 [英] Show Default Image in Image control

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

问题描述

亲爱的专家,



当原始图像丢失时,我需要在我的图像控件中显示默认图片....





 <   asp:Image     ID   =  img_user_pic      width   ='  66'    height   ='  80 '    alt   =' 用户名'    class   ='  user-icon'    runat   =  server  /  >  





我该怎么办...请帮帮我..





谢谢和问候,



Dileep

解决方案

在这里你去: -



你可以使用onerror事件,



 <   asp:image     id   =  img_user_pic    width   =  66    height   =  80    alt   = 用户名    class   =  user-icon    runat   =  server    onerror   =  this.onload = null; this.src ='ImageurlORAnyImageHere.jpg';    /  >  





祝你好运。


添加此属性:

 src =/ Images / test.jpg



< asp:image id = img_user_pic width = 66 height = 80 alt = 用户名 class = user-icon runat = server src = / Images / test.jpg xmlns:asp = < span class =code-keyword>#unknown / >





[edit]已添加代码块[/ edit]


Dear Experts,

I need to show a default picture in my image control when the original image is missing....


<asp:Image ID="img_user_pic"  width='66' height='80' alt='User name' class='user-icon' runat="server"/>



how can i do it... please Help me..


Thanks and Regards,

Dileep

解决方案

Here you go:-

you can use onerror event,

<asp:image id="img_user_pic" width="66" height="80" alt="User name" class="user-icon" runat="server" onerror="this.onload = null; this.src='ImageurlORAnyImageHere.jpg';" />



Good luck.


Add this attribute:

src="/Images/test.jpg"



<asp:image id="img_user_pic" width="66" height="80" alt="User name" class="user-icon" runat="server" src="/Images/test.jpg" xmlns:asp="#unknown" />



[edit]Code block added[/edit]


这篇关于在图像控件中显示默认图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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