ToggleState from code-behind

4 posts, 0 answers
  1. David
    David avatar
    159 posts
    Member since:
    Mar 2014

    Posted 20 Dec 2014 Link to this post

    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?
  2. Misho
    Admin
    Misho avatar
    129 posts

    Posted 24 Dec 2014 Link to this post

    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.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. David
    David avatar
    159 posts
    Member since:
    Mar 2014

    Posted 24 Dec 2014 in reply to Misho Link to this post

    This is not exactly what i was looking for, but i'll try to apply it to my needs. Thank you
  5. Misho
    Admin
    Misho avatar
    129 posts

    Posted 26 Dec 2014 Link to this post

    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.

     
Back to Top