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

ToggleState from code-behind

3 Answers 164 Views
Button
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
Iron
Iron
Veteran
David asked on 20 Dec 2014, 07:17 PM
I set togglestate of RadButton on client-side by using set_selectedToggleStateIndex() function which works fine. However, when i try to read the state in code-behind (SelectedToggleState.Text) it returns different text than i see on the screen.
Am i missing something?

3 Answers, 1 is accepted

Sort by
0
Misho
Telerik team
answered on 24 Dec 2014, 11:42 AM
Hello,

It seems that you have been following the right approach to achieve the desired behavior of RadButton.
I've created a sample code snippet as well as a video showing the implementation:

<form id="form1" runat="server">
        <asp:ScriptManager runat="server"></asp:ScriptManager>
        <telerik:RadButton ButtonType="ToggleButton" ToggleType="CustomToggle"  ID="ToggleButton1" runat="server" >
                        <ToggleStates>
                            <telerik:RadButtonToggleState Text="RadButton Toggle State 0" Selected="true"/>
                            <telerik:RadButtonToggleState Text="RadButton Toggle State 1" />
                        </ToggleStates>
                    </telerik:RadButton>
        <br />
        <input type="button" id="InputButton1" value="set_selectedToggleStateIndex(0)" onclick="InputButtonClicked(0)" />
        <input type="button" id="InputButton2" value="set_selectedToggleStateIndex(1)" onclick="InputButtonClicked(1)" />
        <br/>
        <asp:Button runat="server" ID="PostbackButton1" OnClick="PostbackButton1Clicked" Text="Get SelectedToggleState on the server" />
        <script type="text/javascript">
            function InputButtonClicked(newIndex) {
                //alert(newIndex);
                $find("ToggleButton1").set_selectedToggleStateIndex(newIndex);
               
            }
               </script>
        <script runat="server">
            protected void PostbackButton1Clicked(object sender, EventArgs e)
            {
                Response.Write(ToggleButton1.SelectedToggleState.Text);
            }
         
        </script>
    </form>

I hope that helps.

Best Regards,
Misho
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
David
Top achievements
Rank 1
Iron
Iron
Veteran
answered on 24 Dec 2014, 02:47 PM
This is not exactly what i was looking for, but i'll try to apply it to my needs. Thank you
0
Misho
Telerik team
answered on 26 Dec 2014, 09:13 AM
Hi,

I hope the provided information will help you to configure RadButton in accordance with your custom scenario.
If you have further questions, please don’t hesitate to contact us.


Regards,
Misho
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Button
Asked by
David
Top achievements
Rank 1
Iron
Iron
Veteran
Answers by
Misho
Telerik team
David
Top achievements
Rank 1
Iron
Iron
Veteran
Share this question
or