[CLOSED] Button Icon

  1. #1

    [CLOSED] Button Icon

    Hello!
    I need to draw a flag icon in a button in order to show the selected language.
    The button is in _Header.cshtml, so I don't have codebehind.
    I would like to set it via javascript.

    The following code works fine:

          <ext-button id="LanguageButton"
                        variant="Light"
                        scale="Medium"
                        text=""
                        hidden="false"
                        icon="/images/flag_italy.png"
                        margin="5"
                        onClientClick="">
                <menu>
                    <ext-menu plain="true">
                        <items>
                            <ext-menuItem id="LangItMenuItem" text="Italiano" icon="/images/flag_italy.png">
                                <listeners>
                                    <click handler="alert('Italiano!');" />
                                </listeners>
                            </ext-menuItem>
                            <ext-menuItem id="LangEnMenuItem" text="English" icon="/images/flag_usa.png">
                                <listeners>
                                    <click handler="alert('English!');" />
                                </listeners>
                            </ext-menuItem>
                        </items>
                    </ext-menu>
                </menu>
            </ext-button>
    I would like to create a js which reads inside a cookie the preferred language and sets the correct icon to the LanguageButton.

    App.LanguageButton.setIcon('...') or App.LanguageButton.icon = '...' do not work;
    I tried to use the iconCls but it becomes white (maybe because of a wrong implementation).

    .bbros-flag-it {
        background:url(/images/flag_italy.png);
    }
    Could you please help me?
    Thank you much!
    Last edited by fabricio.murta; Sep 25, 2021 at 4:01 PM. Reason: The issue was transient and couldn't be reproduced by either party at some point.
  2. #2
    I'm sorry for asking you, I don't know what was wrong yesterday but
    App.LanguageButton.setIcon('/images/flag_usa.png')
    do work as expected.
  3. #3
    Hello @bbros!

    Sorry for the delay getting back to you.

    I'm not sure why you are randomly getting it. There could have been a typo, maybe? I have tested a sample using your code block and it referenced the image URL the way we would expect. Of course, in my case it was blank simply because I didn't have any file in the specified path. Once the file was fixed, it was displayed.

    Anyway, let us know if this issue hits you again!
    Fabrício Murta
    Developer & Support Expert
  4. #4
    Thank you, it is still working... I really don't know what happened.
    you can consider this thread as closed.
  5. #5
    Alright, thanks for the feedback, and glad it didn't happen again, hopefully never will! :)

    Marking as closed.
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. [CLOSED] Custom Icon on a Button
    By xtoolz in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Jun 13, 2014, 8:31 AM
  2. [CLOSED] Changing Button Icon
    By MarginPoint in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Mar 11, 2014, 10:57 AM
  3. [CLOSED] how to change button's icon in 2.0
    By Fahd in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Jul 12, 2012, 8:59 PM
  4. Icon button and user controls
    By maxdiable in forum 1.x Help
    Replies: 3
    Last Post: May 14, 2010, 2:33 AM
  5. [CLOSED] [1.0] button's icon not displayed
    By PoloTheMonk in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Jan 07, 2010, 7:36 AM

Posting Permissions