Alternate Image

  1. #1

    Alternate Image

    On the following example, the second Image shows an alternate image because it was not able to load the image defined on ImageUrl property (line 29)

    <!DOCTYPE html>
    <html>
    <head runat="server">
        <script type="text/javascript">
            Ext.net.Image.override({
                afterRender: function () {
                    var me = this, alternateImageUrl = me.alternateImageUrl;
                    if (alternateImageUrl) {
                        me.imgEl.on("error", function () {
                            if ((me.imageUrl || me.src) != alternateImageUrl) {
                                me.setImageUrl(alternateImageUrl);
                            }
                        }, me);
                    }
                    me.callParent(arguments);
                }
            });
        </script>
    </head>
    <body style="background-color: lightgray;">
        <ext:ResourceManager ScriptMode="Debug" Theme="Crisp" runat="server" />
        <%--Shows the image--%>
        <ext:Image ImageUrl="http://speed.ext.net/identity/extnet-50x50-cog.png" Width="50" Height="50" runat="server">
            <CustomConfig>
                <ext:ConfigItem Name="alternateImageUrl" Value="http://speed.ext.net/identity/extnet-50x50-cog-white.png" />
            </CustomConfig>
        </ext:Image>
        <%--shows the alternate image--%>
        <ext:Image ID="_img" ImageUrl="http://speed.ext.net/identity/INVALID.png" Width="50" Height="50" runat="server">
            <CustomConfig>
                <ext:ConfigItem Name="alternateImageUrl" Value="http://speed.ext.net/identity/extnet-50x50-cog-white.png" />
            </CustomConfig>
        </ext:Image>
    </body>
    </html>
    Last edited by RaphaelSaldanha; Jun 28, 2016 at 6:18 PM.

Similar Threads

  1. Replies: 2
    Last Post: Feb 26, 2016, 1:17 PM
  2. [CLOSED] Changing the alternate row color for grid
    By RCM in forum 2.x Premium Help
    Replies: 6
    Last Post: Dec 03, 2012, 6:25 AM
  3. Replies: 1
    Last Post: May 16, 2012, 1:57 PM
  4. Alternate Row color in GridPanel not displayed?
    By venu.sn2009 in forum 1.x Help
    Replies: 0
    Last Post: Jun 24, 2011, 7:03 AM
  5. TextArea and Checkbox Alternate Text
    By jmilton in forum 1.x Help
    Replies: 3
    Last Post: Feb 03, 2010, 9:58 PM

Posting Permissions