Toggle button no postback

6 posts, 0 answers
  1. Yaniv
    Yaniv avatar
    6 posts
    Member since:
    Sep 2013

    Posted 23 Jun 2014 Link to this post

    Hi, when i am trying to do a toggle button without postback from the demos it works ok.
    My question is: when i do an action on the OnClientCheckedChanging, it makes the toggle button do a postback. Can i click the button without postback and execute the "OnClientCheckedChanging"?

    The markup:

      <telerik:RadButton ID="btnPlayPause" runat="server" ButtonType="ToggleButton" ToggleType="CheckBox"  OnClientCheckedChanging="OnClientCheckedChanging"  Width="58px" Height="59px"
    AutoPostBack="false" ForeColor="Black" Checked="true" Skin="Metro">
                <ToggleStates>
                    <telerik:RadButtonToggleState ImageUrl="img/play/play.png" HoveredImageUrl="img/play/playHov.png"
                        Text="Play" Selected="true"></telerik:RadButtonToggleState>
                    <telerik:RadButtonToggleState ImageUrl="img/play/pause.png" HoveredImageUrl="img/play/pauseHov.png"
                        Text="Pause"></telerik:RadButtonToggleState>
                </ToggleStates>
      </telerik:RadButton>
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 23 Jun 2014 in reply to Yaniv Link to this post

    Hi Yaniv,

    The default behavior of the control is that by setting AutoPostBack as false it will not make postback. The provided code is working fine at my end. Please make sure that in your code there is no server call related to this button ,because such a behavior is not expected. Please have a look into this help documentation to get more information about OnClientCheckedChanging event.

    Please provide your full code for further help.
    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Yaniv
    Yaniv avatar
    6 posts
    Member since:
    Sep 2013

    Posted 23 Jun 2014 in reply to Princy Link to this post

    Hi, the button does not postback as long as OnClientCheckedChanging is not set and AutoPostBack="false".
    When i add OnClientCheckedChanging the button itself does post back. Please try it and see.
    Thank you.
  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 24 Jun 2014 in reply to Yaniv Link to this post

    Hi Yaniv,

    Unfortunately I couldn't replicate the issue at my end.

    Thanks,
    Princy.
  6. Charlie
    Charlie avatar
    1 posts
    Member since:
    Mar 2011

    Posted 20 Jul 2015 Link to this post

    I am having the same exact issue when adding "OnClientCheckedChanged" to a Toggle button.  Autopostback is set to false.  If "OnClientCheckedChanged" is there, then it will post back.  If not, no postback as expected.
  7. Danail Vasilev
    Admin
    Danail Vasilev avatar
    1490 posts

    Posted 23 Jul 2015 Link to this post

    Hi Charlie,

    I am not able to reproduce the issue with the code below:

    ASPX:
    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
        <script>
            function OnClientCheckedChanged(sender, args) {
                console.log('OnClientCheckedChanged');
            }
        </script>
        <telerik:RadButton ID="RadButton1" runat="server" Checked="true" ToggleType="CheckBox" ButtonType="ToggleButton" AutoPostBack="false" OnClientCheckedChanged="OnClientCheckedChanged">
            <ToggleStates>
                <telerik:RadButtonToggleState Text="Checked" Selected="true" />
                <telerik:RadButtonToggleState Text="Unchecked" />
            </ToggleStates>
        </telerik:RadButton>
    </form>

    It may be possible that some JavaScript errors is thrown, so a postback is performed. Can you ensure there aren't such JavaScript errors on your page or when the button is clicked?

    Another thing I can suggest is that you check your Telerik UI version. If it is not the latest official one - 2015.2.623, does upgrading to it helps?

    Otherwise I would suggest that you try to reproduce the issue with the above code and then tell us what changes you have made, so that I can investigate it further.

    Regards,
    Danail Vasilev
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017