I have several slider values contained in an accordion panel. I have a button, btnResetSliders, that I use to reset all the values of the sliders to zero (0). I've tried all kinds but it just isn't working. The button html tag is as follows:
..and so on. The sliders are in Default.aspx web page. I'm using a Master page. I placed the javascript at the bottom of the Default.aspx page, just before the </asp:Content> tag . The javascript is as follows:
<script type="text/javascript">
function resetValue() {
document.getElementById("CroplandSlider").value = 0;
... all other sliders here....
}
</script>
Member
68 Points
342 Posts
Problem resetting slider values
May 06, 2015 10:00 AM|mgambone|LINK
Hi,
I have several slider values contained in an accordion panel. I have a button, btnResetSliders, that I use to reset all the values of the sliders to zero (0). I've tried all kinds but it just isn't working. The button html tag is as follows:
<asp:Button ID="btnReset" runat="server" Text="Reset Sliders" Width="150px" OnClick="btnReset_Click"/>
The sliders are inside <ul><li> tags. See sample snippet below:
<ul>
<li><h4>Cropland</h4></li>
<div id="sliderDiv" >
<asp:Label ID="CroplandSlider_BoundControl" runat="server" AssociatedControlID="CroplandSlider" />
<asp:TextBox ID="CroplandSlider" runat="server" AutoPostBack="True" Text="0" BorderStyle="None"
OnTextChanged="CroplandSlider_TextChanged" ClientIDMode="Static" />
<ajaxToolkit:SliderExtender ID="CroplandSliderExtender" runat="server"
Enabled="true"
BehaviorID="CroplandSlider"
TargetControlID="CroplandSlider"
Minimum="-100"
Maximum="100"
BoundControlID="CroplandSlider_BoundControl"
RailCssClass="croplandrail"
HandleCssClass="croplandhandle"
HandleImageUrl="~/images/sliders/cropland_handle.png"
EnableHandleAnimation="true">
</ajaxToolkit:SliderExtender>
</div>
</li>
</ul>
..and so on. The sliders are in Default.aspx web page. I'm using a Master page. I placed the javascript at the bottom of the Default.aspx page, just before the </asp:Content> tag . The javascript is as follows:
<script type="text/javascript">
function resetValue() {
document.getElementById("CroplandSlider").value = 0;
... all other sliders here....
}
</script>
The code behind:
protected void btnReset_Click(object sender, EventArgs e)
{
If (Page.IsPostBack)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "JSScript", "resetValue();", true);
}
}
It has no effect whatsoever on the values or location of the slider handles.
Appreciate any help.