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

Create ToggleStates collection programmatically

1 Answer 112 Views
Button
This is a migrated thread and some comments may be shown as answers.
Fit2Page
Top achievements
Rank 2
Iron
Iron
Iron
Fit2Page asked on 05 Mar 2012, 11:21 AM
Hi all,

How do I create a ToggleStates collection for a dynamic created ToggleButton?

I want these 2  comined from codebehind:

        Dim radButton1 As New RadButton()
        radButton1.ButtonType = RadButtonType.ToggleButton
        radButton1.ToggleType = ButtonToggleType.CheckBox
        radButton1.AutoPostback = False
        
        '<ToggleStates>
                        '<telerik:RadButtonToggleState ImageUrl="img/play/play.png" HoveredImageUrl="img/play/playHov.png"
                           'Text="Play" Selected="true" />
                        '<telerik:RadButtonToggleState ImageUrl="img/play/pause.png" HoveredImageUrl="img/play/pauseHov.png"
                            'Text="Pause" />
                    '</ToggleStates>

Thanks,
Marc

1 Answer, 1 is accepted

Sort by
0
Kevin
Top achievements
Rank 2
answered on 05 Mar 2012, 02:29 PM
Hello Fit2Page,

All you need to do is create RadButtonToggleState objects and just add them to the ToggleStates collection of the RadButton. Like so:

Dim state1 As New RadButtonToggleState("Play")
Dim state2 As New RadButtonToggleState("Pause")
  
radButton1.ToggleStates.Add(state1)
radButton1.ToggleStates.Add(state2)

The above code is a simple implementation where I just pass the text for the button, but you can add the other properties as well.

I hope that helps.
Tags
Button
Asked by
Fit2Page
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Kevin
Top achievements
Rank 2
Share this question
or