0

I am looking for something similar to the OnTextChanged property of a TextBox control. So that when the Text value of a label is changed, a particular function is called to do my particular staff.

MarkUp

 <asp:TextBox ID="TextBox2"   runat="server"></asp:TextBox>

    <asp:Label ID="Label1" runat="server"  Text="Label"></asp:Label>

    <asp:SliderExtender ID="SliderExtender1"  TargetControlID="TextBox2"  BoundControlID="Label1" Maximum="200" Minimum="100" runat="server">
    </asp:SliderExtender>
Md. Arafat Al Mahmud
  • 3,124
  • 5
  • 35
  • 66

2 Answers2

2

Handle the appropriate OnChange event of the slider instead. The only way the label text can change is if your code changes it.

EDIT

Hmmm. You could try binding the slider to a non-visible asp:TextBox, then use the OnChange event from that to update your Label and call your function.

Dan Pichelman
  • 2,312
  • 2
  • 31
  • 42
0

Observing 'input' event instead of 'change'

jQuery('#textboxid').live('input', function() {
    // do your stuff
})

or for your slider using 'change' event

$('#sliderid').live('change', function() {
     $('#textboxid').val('some text').trigger('change');
});

may be this way instead of change event. (The 'change' event doesn't work correctly, but the 'input' is perfect.)

$('#your_textbox').bind('input', function() {
    /* This will be fired every time, when textbox's value changes. */
});

This jQuery code catches immediate changes to any element,

$('.myElements').each(function() {
    // Save current value of element
    $(this).data('oldVal', $(this).val());

    // Look for changes in the value
    $(this).bind("propertychange keyup input paste", function(event){
    // If value has changed...
        if ($(this).data('oldVal') != $(this).val()) {
            // Updated stored value
            $(this).data('oldVal', $(this).val());

            // Do action
            ....
        }
    });
});

by phatmann

Community
  • 1
  • 1
Mojtaba Pourmirzaei
  • 306
  • 1
  • 6
  • 17