Slider extender, client events

Last post 01-04-2007 9:11 PM by huenemeca. 5 replies.

Sort Posts:

  • Slider extender, client events

    11-29-2006, 9:54 AM
    • Loading...
    • DanNsk
    • Joined on 03-30-2006, 11:59 AM
    • Novosibirsk/Russia
    • Posts 6
    I have slider extender on a page , which is bound to a hidden field, and has some textbox as an target control.
    Slider extender has valueChanged event, is there any way to attach my handler to it ?
    My idea was $find('controlId').add_valueChanged( function() {} ); , but doesn't work.

     
  • Re: Slider extender, client events

    11-29-2006, 4:22 PM
    • Loading...
    • Garbin
    • Joined on 09-17-2004, 12:35 PM
    • Sassari, Italy
    • Posts 1,494
    • ASPInsiders
      TrustedFriends-MVPs

    Hi,

    you can give an id to the behavior using the BehaviorID property in the extender control. Then, you can write

    $find('behaviorID').add_valueChanged(function() { alert('value changed!'); });
     

    Alessandro Gallo | Blog | My book: ASP.NET AJAX In Action
  • Re: Slider extender, client events

    11-30-2006, 12:27 AM
    • Loading...
    • DanNsk
    • Joined on 03-30-2006, 11:59 AM
    • Novosibirsk/Russia
    • Posts 6
    I forgot to tell that i'm trying to add this script dynamically, in a Page_Load event handler of a page
    so the only working solution i've found -


    string script = "Sys.Application.add_init(function() {\n" +
    " var slider1 = $find('" + SliderExtender1.BehaviorID + "');\n" +
    " if (slider1) slider1.add_valueChanged(function() { alert('value changed!'); });\n" +
    " });\n";

    ScriptManager.RegisterStartupScript(Page, GetType(), "StartupValuesFunction", script, true);

  • Re: Slider extender, client events

    01-04-2007, 11:32 AM
    • Loading...
    • huenemeca
    • Joined on 08-02-2002, 10:19 AM
    • Posts 163

    Hello,

    I am trying to get this to work so that I can have the slider use a AJAX call to report it's position to the system.  But when I use $find('BehaviorID') I get null.  I am actually using the behaviorID of the slider extender control.  Can you show me an example of this working? 

    Also, is there any plans to add the valueChanged event to the Extender so that I can just say ValueChanged='myjavascriptFunction'?  It seems like a control in the AJAX toolkit should have this sort of functionality.

    Thanks,
    Mike
     

    Filed under:
  • Re: Slider extender, client events

    01-04-2007, 12:01 PM
    • Loading...
    • Garbin
    • Joined on 09-17-2004, 12:35 PM
    • Sassari, Italy
    • Posts 1,494
    • ASPInsiders
      TrustedFriends-MVPs

    Hi,

    please check the following example: 

    <%@ Page Language="C#" %>
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Slider Example</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <asp:ScriptManager ID="TheScriptManager" runat="server"></asp:ScriptManager>
        
        <asp:TextBox ID="txtSlider" runat="server"></asp:TextBox>
        <asp:Label ID="lblSliderBound" runat="server"></asp:Label>
        
        <ajaxToolkit:SliderExtender ID="SliderExtender1" runat="server"
            TargetControlID="txtSlider" BoundControlID="lblSliderBound" BehaviorID="sliderBehavior"
            Steps="3"></ajaxToolkit:SliderExtender>
        
        <script type="text/javascript">
        <!--
            function pageLoad(sender, e) {
                var slider = $find('sliderBehavior');
                slider.add_valueChanged(onValueChanged);
            }
            
            function onValueChanged(sender, e) {
                alert('Value changed!');
            }
        //-->
        </script>
        </form>
    </body>
    </html>
     

    Alessandro Gallo | Blog | My book: ASP.NET AJAX In Action
  • Re: Slider extender, client events

    01-04-2007, 9:11 PM
    • Loading...
    • huenemeca
    • Joined on 08-02-2002, 10:19 AM
    • Posts 163
Page 1 of 1 (6 items)
Microsoft Communities
Page view counter