0
Hello, I’m making a web page on which images are taken from outside the server, but sometimes the image no longer exists, or the link broke, so I’d like to display another image. The code would be like this:
@if(condição de imagem existe){
<img src="@imgUrl"/>
}else{//aqui é quando a imagem não for encontrada, se isso ocorrer eu quero que carregue uma imagem do meu servidor
<img src="/img.jpg"/>
}
I think this can help you https://answall.com/questions/321138/howto make a styling-break imagem-break imagem-when a-imagem-n%C3%a3o-load but it’s only with HTML/CSS, there are JS responses there tb that works exactly as you want it
– hugocsl
i would like to do without javascript, since I am using Razor to build the page.
– igor3k