Building Radio Button Back End

2 posts, 1 answers
  1. Joe
    Joe avatar
    2 posts
    Member since:
    Dec 2016

    Posted 23 Dec 2016 Link to this post

    Hello!

    I was wondering if there was a way on the back end to setup the toggle states like:

                    <ToggleStates>
                        <telerik:RadButtonToggleState Text="Checked" PrimaryIconCssClass="rbToggleRadioChecked"></telerik:RadButtonToggleState>
                        <telerik:RadButtonToggleState Text="UnChecked" PrimaryIconCssClass="rbToggleRadio"></telerik:RadButtonToggleState>
                    </ToggleStates>

     

    My current code is something like this:

     RadButton button = new RadButton();
                            button.GroupName = rbl.ID;
                            button.ToggleType = ButtonToggleType.Radio;
                            button.ButtonType = RadButtonType.StandardButton;
                            button.AutoPostBack = false;
                            button.Text = row.option_name;
                            button.Value = row.option_value;
                            button.RenderMode = RenderMode.Lightweight;
                            button.Icon.PrimaryIconCssClass = "rbToggleRadio";

    Would I have to set an on change to handle changing the PrimaryIconCssClass?

  2. Answer
    Ianko
    Admin
    Ianko avatar
    1630 posts

    Posted 27 Dec 2016 Link to this post

    Hello Joe,

    Yes, you can, by adding RadButtonToggleState instances to the ToggleStates collection of RadButton: 

    ...
    button.ToggleStates.Add(new RadButtonToggleState("Checked") { PrimaryIconCssClass = "rbToggleRadioChecked" });
    button.ToggleStates.Add(new RadButtonToggleState("UnChecked") { PrimaryIconCssClass = "rbToggleRadio" });
    ...

    Regards,
    Ianko
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top