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

Toggle button no postback

5 Answers 244 Views
Button
This is a migrated thread and some comments may be shown as answers.
Yaniv
Top achievements
Rank 1
Yaniv asked on 23 Jun 2014, 10:39 AM
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>

5 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 23 Jun 2014, 12:20 PM
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.
0
Yaniv
Top achievements
Rank 1
answered on 23 Jun 2014, 12:51 PM
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.
0
Princy
Top achievements
Rank 2
answered on 24 Jun 2014, 10:05 AM
Hi Yaniv,

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

Thanks,
Princy.
0
Charlie
Top achievements
Rank 1
answered on 20 Jul 2015, 10:24 PM
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.
0
Danail Vasilev
Telerik team
answered on 23 Jul 2015, 08:37 AM
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
Tags
Button
Asked by
Yaniv
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Yaniv
Top achievements
Rank 1
Charlie
Top achievements
Rank 1
Danail Vasilev
Telerik team
Share this question
or