Here is my unique HTML code consisting of a single div and an image positioned outside the div.
<div runat="server" id="ProductThumbnail" style="width:140px;height:140px;position:relative;background-position:center;background-repeat:no-repeat;">
<asp:Image ID="ProductThumbnail1" runat="server" Style="max-height: 50px;position:absolute;right:0px;top:0px;" />
</div>
<asp:Image ID="Imagealt" runat="server" />
The purpose here is to dynamically set the background image of the div from the server-side code like so:
ProductThumbnail.Style.Add("BACKGROUND-IMAGE", "url(" + Item.ThumbnailUrl.Replace("~", "..") + ")");
The goal is to display alternate text in Imagealt if there is no background image for the div. If the background image exists, then hide Imagealt.
This functionality needs to be implemented using both server-side code and JavaScript.
Please refer to the example image below: https://i.sstatic.net/OrhdV.png
**On the left side, where the div image is missing, the alt text appears correctly. However, on the right side, even though the image is displayed, the alt text still shows up - which is incorrect.
I only want to show the alt text when the div background image is not displayed.**
1- No alt text should appear if an image is present.
2- Show alt text only when the image is not displayed.
For example:
If the URL path of the div's background image is set to:
http://meenaprints.in/Admin/images/productimg/thumbnail/436x636_4736.jpg
then the alt text should not be displayed as this URL retrieves an image.
However,
If the URL path of the div's background image is set to:
http://meenaprints.in/Admin/images/productimg/thumbnail/436x636_473123.jpg
which does not retrieve an image, then the ALT text should be displayed.