Click here to Skip to main content
15,905,508 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Experts,

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


ASP.NET
<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
Posted

Here you go:-

you can use onerror event,

ASP.NET
<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.
 
Share this answer
 
v2
Add this attribute:
ASP.NET
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]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900