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

Block Slider Auto Postback

1 Answer 104 Views
Slider
This is a migrated thread and some comments may be shown as answers.
Yuri Kovalenko
Top achievements
Rank 1
Yuri Kovalenko asked on 04 Feb 2009, 09:56 AM
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.

1 Answer, 1 is accepted

Sort by
0
Tsvetie
Telerik team
answered on 09 Feb 2009, 03:48 PM
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.
Tags
Slider
Asked by
Yuri Kovalenko
Top achievements
Rank 1
Answers by
Tsvetie
Telerik team
Share this question
or