locked
AjaxControlToolkit Slider's TextChanged event not firing RRS feed

  • Question

  • User-94285869 posted

    Hi,

    I need for the slider to execute a code behind when users slide it and stop.  Somehow, the code behind method is not firing.  Does anyone have a solution?  Below is my C# code:

    protected void CroplandSlider_TextChanged(object sender, EventArgs e)
    {
      //get value from dropdownlist
      string huccode = ddlHuccodes.Text;
      
      //call the method
      DisplayScenarioPieChart(huccode);
    }

    ASPX:

    <ajaxToolkit:SliderExtender ID="CroplandSliderExtender" runat="server">
      BehaviorID = "CroplandSlider"
      Minimum=-100
      Maximum=100
      BoundControlID="CroplandSlider_BoundControl"
      RailCssClass="croplandrail"
      HandleCssClass="croplandhandle"
      HandleImageUrl="~/images/sliders/corn_handle.png"
      RaiseChangeOnlyOnMouseUp="true"
      EnableHandleAnimation="true">
    </ajaxToolkit:SliderExtender>

    <div>
      <asp:Label ID="CroplandSlider_BoundControl" runat="server" AssociatedControlID="CroplandSlider"/>
      <asp:TextBox ID="CroplandSlider" runat="server" AutoPostBack="True" Text="0" BorderStyle="None" ReadOnly="true" OnTextChanged="CroplandSlider_TextChanged"/>
    </div>

    I can't figure out why the method is not firing when user stop sliding.  Appreciate any help.


      
     

    Tuesday, March 3, 2015 8:44 AM

Answers

  • User-94285869 posted

    Hi,

    Found the error in my code.  I specified "ReadOnly=true"  property in my Slider's TextBox.  I removed this and then specified the property "RaiseChangeOnlyOnMouseUp=true" in my SliderExtender and it's working now.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, March 3, 2015 10:48 AM

All replies

  • User-94285869 posted

    Hi,

    Found the error in my code.  I specified "ReadOnly=true"  property in my Slider's TextBox.  I removed this and then specified the property "RaiseChangeOnlyOnMouseUp=true" in my SliderExtender and it's working now.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, March 3, 2015 10:48 AM
  • User61956409 posted

    Hi mgambone,

    Thanks for your post.

    Firstly, I’m glad to hear you resolve the problem by yourself. And thanks for sharing us your solution.

    Secondly, you set TextBox.ReadOnly Property to true, it indicates the contents of the TextBox control cannot be changed. TextBox.TextChanged Event occurs when the content of the text box changes between posts to the server, so TextChanged Event does not fire if you set ReadOnly property to true.

    Best Regards,

    Fei Han

    Tuesday, March 3, 2015 9:34 PM