Aug 25, 2017, 8:03 AM
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