3 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 09 Oct 2009, 05:23 AM
Hi Eddie,
Here is the example which shows how to set/get the background color of RadListBoxItem from clientside.
aspx:
javascript:
-Shinu.
Here is the example which shows how to set/get the background color of RadListBoxItem from clientside.
aspx:
<telerik:RadListBox ID="RadListBox1" runat="server"> |
<Items> |
<telerik:RadListBoxItem runat="server" Text="RadListBoxItem1" /> |
<telerik:RadListBoxItem runat="server" Text="RadListBoxItem2" /> |
. . . |
</Items> |
</telerik:RadListBox> |
<input id="Button1" type="button" value="set" onclick="setColor();" /> |
<input id="Button2" type="button" value="get" onclick="getColor();" /> |
javascript:
<script type="text/javascript"> |
function setColor() { |
var listBox = $find('<%= RadListBox1.ClientID %>'); |
var item = listBox.findItemByText("RadListBoxItem1"); |
item.get_element().style.backgroundColor = "red"; |
} |
function getColor() { |
var listBox = $find('<%= RadListBox1.ClientID %>'); |
var item = listBox.findItemByText("RadListBoxItem1"); |
alert(item.get_element().style.backgroundColor); |
} |
</script> |
-Shinu.
0
Abhay
Top achievements
Rank 1
answered on 24 Feb 2011, 10:59 AM
Is it possible to change clour of rad listbox, when it is empty or it contens no record.
0
Shinu
Top achievements
Rank 2
answered on 24 Feb 2011, 01:16 PM
Hello Abhay,
You can try the following client side code by subscribing the RadListBox event event OnClientLoad.
Here is the code which fired on the ClientLoad
ClientSide:
Thanks,
Shinu.
You can try the following client side code by subscribing the RadListBox event event OnClientLoad.
Here is the code which fired on the ClientLoad
ClientSide:
function
OnClientLoad(sender, args)
{
var
listbox = $find(
"<%= RadListBox1.ClientID %>"
);
if
(listbox.get_items().get_count() == 0)
{
listbox.get_element().style.backgroundColor =
"Red"
;
}
}
Thanks,
Shinu.