根据您获取图像的方式,这可能会有所不同
<html>
<body>
<img src="<dynamic handler url>" alt="My Username" onError="this.src='defaultProfile.jpg';" />
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
这就是你在ASP.NET中的表现.
设计师 -
<asp:Image ImageUrl="NonexistentImage.Jpg" ID="profileImage" Height="50" Width="50" runat=server />
Run Code Online (Sandbox Code Playgroud)
代码背后(c#)
profileImage.Attributes["onerror"] = "this.src='http://www.cs.uofs.edu/~olivetoj2/blah.jpg';";
Run Code Online (Sandbox Code Playgroud)
这对我来说非常适合.
| 归档时间: |
|
| 查看次数: |
15579 次 |
| 最近记录: |