Hello,
I'm having trouble overriding the default .rcbHover css in a customized skin.
I have a single ComboBox with a custom skin derived from Web20. I have a situation where I need to apply a specific item style based on some conditions. I do this by setting the RadComboBoxItem's CssClass property in the code-behind. The problem I'm encountering is that when the user hovers over the specific item with the new class I get the default hover class.
My code may help explain:
ASPX:
<script language="javascript" type="text/javascript"> |
function cboOpening(sender, eventArgs) |
{ |
//alert('cboOpening() called.'); |
if (sender.get_items().get_count() <= 1) |
sender.requestItems(sender.get_text(),false); |
} |
</script> |
<telerik:RadComboBox ID="cbo" Runat="server" Height="200px" Width="400px" AutoPostBack="true" |
EnableLoadOnDemand="false" |
ShowDropDownOnTextboxClick="true" |
MarkFirstMatch="true" |
AllowCustomText="false" |
ShowMoreResultsBox="false" |
ItemRequestTimeout="500" |
OnItemsRequested="cbo_ItemsRequested" EnableViewState="false" |
OnSelectedIndexChanged="cbo_SelectedIndexChanged" |
OnClientDropDownOpening="cboOpening"> |
</telerik:RadComboBox> |
C#:
protected void Page_Load(object sender, EventArgs evt) |
{ |
if (!Page.IsPostBack) |
{ |
cbo.Items.Clear(); |
cbo.Items.Add(new RadComboBoxItem(some_text)); |
cboHEs.SelectedIndex = 0; |
} |
} |
public void cbo_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs evt) |
{ |
SessionMgr.ValidateSession(); |
LoadCBO(); |
} |
protected void cbo_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs evt) |
{ |
string selectedText = cbo.Text; |
if ((selectedText != null) && (selectedText .Trim().Length > 0)) |
{ |
// Do some stuff... |
} |
} |
protected void LoadCBO() |
{ |
cbo.Items.Clear(); |
foreach (Object obj in ObjectList) |
{ |
RadComboBoxItem item = new RadComboBoxItem(obj.ToString()); |
cbo.Items.Add(item); |
if (_someCondition_) |
{ |
item.CssClass = "NewOverrideClass"; |
} |
} |
} |
Finally the CSS:
.RadComboBoxDropDown_CustomSkin .NewOverrideClass |
{ |
background-image: url('image.gif'); |
background-repeat: no-repeat; |
background-position: top right; |
padding: 2px 6px; |
margin: 0 1px; |
} |
.RadComboBoxDropDown_CustomSkin .rcbHovered // <-- This is the default hover class |
{ |
padding: 1px 18px 1px 5px; |
border: 1px solid #bcd2f1; |
background: #e7f1ff; |
color: #0f3789; |
} |
I've tried overriding by trying CSS inheritance (probably wrong)...
.RadComboBoxDropDown_CustomSkin .NewOverrideClass .rcbHovered
{
padding: 1px 18px 1px 5px;
border: 1px solid #bcd2f1;
background: #e7f1ff;
color: #0f3789;
}
Any help is appreciated!
-Allen