Block Slider Auto Postback

2 posts, 0 answers
  1. Yuri Kovalenko
    Yuri Kovalenko avatar
    1 posts
    Member since:
    Oct 2008

    Posted 04 Feb 2009 Link to this post

    I have slider with AutoPostBack property set to "true". How can I block auto postback when changing value of a slider with the client side API? E. g. I don't need postback to fire when running this code:
    $find('slider_name').set_value(0);
    At the same time I need postback to fire when I change value of a slider by Drag Handle.
  2. Tsvetie
    Admin
    Tsvetie avatar
    1517 posts

    Posted 09 Feb 2009 Link to this post

    Hello Yuri,
    You cannot block the postback using the client-side API of the RadSlider. You can only cancel the ValueChange operation using the OnClientBeforeValueChange handler. Basically, in this case, you can think of the RadSlider as of a simple ASP Button. You can block the postback of the slider the same way you can block the postback of a Button when a certain condition is met.

    For example:
    <script type="text/javascript"
    var toPostBack = true
    function OnClientValueChange(sender, args) 
        if(toPostBack) 
        { 
            __doPostBack('<%= RadSlider1.ClientID %>'); 
        } 
        else 
        { 
            toPostBack = true
        } 
     
    function ChangeValueWithCode() 
        var slider = $find('<%= RadSlider1.ClientID %>'); 
        toPostBack = false
        slider.set_value(5);             
    </script> 
     
    <asp:Label ID="slValue" runat="server"></asp:Label> 
     
    <telerik:RadSlider ID="RadSlider1" runat="server" 
        AutoPostBack="false" 
        OnClientValueChange="OnClientValueChange"  
        OnValueChanged="RadSlider1_ValueChanged"></telerik:RadSlider> 
         
    <button onclick="ChangeValueWithCode(); return false;">No PostBack</button> 

    protected void RadSlider1_ValueChanged(object sender, EventArgs e) 
        slValue.Text = RadSlider1.Value.ToString(); 

    Best wishes,
    Tsvetie
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top