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

Changing Css programmatically

6 Answers 283 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
luc bonenfant
Top achievements
Rank 1
luc bonenfant asked on 04 Oct 2010, 11:51 AM
Hello,

I'm using Q3 2009.
After selecting an item into the combobox, I would like the combobox css takes its highlight skin. This is a fanciful example to understand my request :

If Not radCombo1.SelectedItem Is Nothing Then
    radCombo1.CssClass = "RadComboBox_Black:hover"
Else
    radCombo1.CssClass = "RadComboBox_Black"
End If

Is it possible to do that please ?
Thank you.

6 Answers, 1 is accepted

Sort by
0
luc bonenfant
Top achievements
Rank 1
answered on 07 Oct 2010, 01:37 PM
Do you understand the question ?
Have you got a solution please ?

Thank you.
0
Kalina
Telerik team
answered on 07 Oct 2010, 02:18 PM
Hello luc bonenfant,

As I understand from your explanations – you use the “Black” RadComboBox Skin and you want the text at the control input to be colored in green after user selects an item (as it is when the control input is hovered) .

Let me suggest you change the RadComboBox input text color at client-side handling the OnClientSelectedIndexChanged event:
<script type="text/javascript">
 
    function OnClientSelectedIndexChangedHandler(sender, eventArgs) {
        if (sender.get_selectedItem() != null) {
            var inputElement = sender.get_inputDomElement();
            inputElement.style.color = "#9eda29";
        }
 
    }
</script>
 
<telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
<telerik:RadComboBox ID="RadComboBox1" runat="server" Skin="Black"
    OnClientSelectedIndexChanged="OnClientSelectedIndexChangedHandler" >
    <Items>
        <telerik:RadComboBoxItem runat="server" Text="ALL" Value="ALL" />
        <telerik:RadComboBoxItem runat="server" Text="A" Value="A" />
        <telerik:RadComboBoxItem runat="server" Text="B" Value="B" />
        <telerik:RadComboBoxItem runat="server" Text="C" Value="C" />
    </Items>
</telerik:RadComboBox>

I hope this helps.

Greetings,
Kalina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
luc bonenfant
Top achievements
Rank 1
answered on 07 Oct 2010, 03:26 PM
I'm sorry, that's not exactly what i need.

If we use Forest skin rather than Black, it's better in fact :
When you highlight the combobox, you can see a light green background instead of the white background. I would like to active this background definitively if one item is selected. So I need to change the css active by the css hover if selection is done.
It can be done from code behind because i make a postback for each combo selected.

Why that ?: i'm using 20 filters filtered with combos. I would like to visually differenciate the selected combos from others.

Thanks.
Luc
0
luc bonenfant
Top achievements
Rank 1
answered on 11 Oct 2010, 04:30 PM
Any Suggestion please ?
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 12 Oct 2010, 05:02 AM
So you just want a way to visually mark a combo as complete?

Why not handle the clientside SelectedIndexChanged event as Kalina suggested.

Then use jQuery to set a "complete" class on the combobox itself (like "RadComboCompleted").  Then the you would just style that element to have something like this
.RadComboCompleted td.rcbInputCellLeft {
    background-position: 0 -176px !important;
}

Then any completed combo gets that style, and CSS handles how it looks.
0
luc bonenfant
Top achievements
Rank 1
answered on 12 Oct 2010, 03:08 PM
Thanks for help, finally the first solution was marvelous !
Tags
ComboBox
Asked by
luc bonenfant
Top achievements
Rank 1
Answers by
luc bonenfant
Top achievements
Rank 1
Kalina
Telerik team
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Share this question
or