This is a migrated thread and some comments may be shown as answers.

Change Item Color Based On Checked.

1 Answer 71 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Teena
Top achievements
Rank 1
Teena asked on 05 Mar 2013, 08:14 AM
Hello,

There is a ListBox control in my user page and I want to change the color of the ListBox item based on the checked state of the item. Suppose if the item is checked the font color should change to blue and on unchecking the font color must change to the original color. I want this to be done from client code.

Thank you,
Teena  

1 Answer, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 05 Mar 2013, 10:49 AM
Hello Teena,

Try the following JavaScript in the OnClientItemChecked event of the RadListBox.

JavaScript:
<script type="text/javascript">
    function OnClientItemChecked(sender, args) {
        if (args.get_item().get_checked() == true) {
            args.get_item()._textElement.style.color = "red"
        }
        else {
            args.get_item()._textElement.style.color = "black"
        }
    }
</script>

Thanks,
Princy.
Tags
ListBox
Asked by
Teena
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or