Asp.net 中继器和默认照片C#2.0

Asp.net 中继器和默认照片C#2.0,asp.net,Asp.net,我们有一个非常简单的页面来显示记录 基本上,它会传递特定的电话号码,如果找到了,就会显示出来,并且有一个潜在的相同号码,这就是为什么要使用repeater。这项工作很好,没有问题,但是现在通过引入需要显示的照片配置文件,需求发生了变化 它的工作方式基本上是一旦返回记录,它就会根据特定文件夹上的PhoneID检查物理照片,如果存在,则显示为“/images/profiles/1.jpg”,如果找不到,则使用“/images/profiles/default.jpg” 但是我无法让它在如何渲染上工作

我们有一个非常简单的页面来显示记录

基本上,它会传递特定的电话号码,如果找到了,就会显示出来,并且有一个潜在的相同号码,这就是为什么要使用repeater。这项工作很好,没有问题,但是现在通过引入需要显示的照片配置文件,需求发生了变化

它的工作方式基本上是一旦返回记录,它就会根据特定文件夹上的PhoneID检查物理照片,如果存在,则显示为“/images/profiles/1.jpg”,如果找不到,则使用“/images/profiles/default.jpg”

但是我无法让它在如何渲染上工作

ASPX:

更改:

<img alt="" src="/images/profiles/<%# DataBinder.Eval(Container.DataItem, "PhotoID") %>" />
“/>
致:

“onerror=”this.onerror=null;this.src='/images/profiles/default.jpg';“/>
当图像返回404时,您将获得默认图像。

更改:

<img alt="" src="/images/profiles/<%# DataBinder.Eval(Container.DataItem, "PhotoID") %>" />
“/>
致:

“onerror=”this.onerror=null;this.src='/images/profiles/default.jpg';“/>
当图像返回404时,您将获得默认图像

<img alt="" src="/images/profiles/<%# DataBinder.Eval(Container.DataItem, "PhotoID") %>" />
<img alt="" src="/images/profiles/<%# DataBinder.Eval(Container.DataItem, "PhotoID") %>" onerror="this.onerror=null;this.src='/images/profiles/default.jpg';" />