Change button icon in codebehind not working as expected

  1. #1

    Change button icon in codebehind not working as expected

    I have this button:

        <ext:Button Flat="true" runat="server" ID="btnCheckV" Icon="CheckError" Scale="Large" ToolTip="Is Valid" >
                <DirectEvents>
                    <Click OnEvent="CheckValidity" />
                </DirectEvents>
        </ext:Button>
    And I want to change the icon of the button in code behind (tick for valid and cross for not valid). So I do it like this:

        protected void CheckValidity(object sender, DirectEventArgs e)
            {
                 //....validation check code
                 if (isValid == true)
                {
                    btnCheckV.Icon = Icon.Tick;
                    e.Success = true;
                }
                else
                {
                    btnCheckV.Icon = Icon.Cross;
                    e.Success = false;
                }
            }
    It works but only the first time I check. If for example the first time I check is valid it turns to tick, but if I check again and the data is invalid it won't change to cross
  2. #2
    Hello @atroul!

    Please check this forum thread:
    - ImageCommandColumn change Icon on client-side issue

    I hope this helps!
    Fabrício Murta
    Developer & Support Expert
  3. #3
    Hello @Fabricio,
    unfortunately it doesn't help.... I put those lines in page load with no luck
    ResourceManager.GetInstance().RegisterIcon(Icon.Tick);
    ResourceManager.GetInstance().RegisterIcon(Icon.Cross);
    If the result is valid the first time it changes to Tick but it wont change to cross if the next check is invalid.
    If the result is invalid the first time it doesnt change to Cross.

    If I swap the icons I can see the Cross icon when its valid for the first time etc.
  4. #4
    Hello @atroul!

    You should be doing something wrong. Without test case, we can't help.
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. [CLOSED] Change button's icon alignment
    By extnetuser in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Aug 21, 2013, 12:48 PM
  2. Replies: 1
    Last Post: Jul 17, 2012, 5:53 PM
  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. [CLOSED] Change button icon and tooltip dinamically
    By Pablo_Azevedo in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Mar 18, 2011, 3:33 PM
  5. [CLOSED] [1.0] MultiCombo Change listener not working as expected
    By jmcantrell in forum 1.x Legacy Premium Help
    Replies: 11
    Last Post: Aug 20, 2010, 3:06 PM

Tags for this Thread

Posting Permissions