Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
280
Getting Dynamic Text Box Value
posted

I have successfully implemented the ValueChanged clientevent to capture the value of hte slider and put it in a text box... this works great when i know the ID of the text box at design time.  However, I'm encapsulating the slider in a compositeControl and need to figure out a way to get the clientID of the textbox at runtime for the slider (there are many of these composite controls on the page so I can't use a static value)

normally i would render out the call to the javascript and put in the client id, but because you have "wrappered" the valuechanged event and force me to only have 2 arguments (this, events) I can't do that.

Is there any way to override the javascript function call and add my own parameters and still have access to the values in the control?

i hope this makes sense.

thanks

 

Parents
No Data
Reply
  • 24497
    posted

    Hi,

    To get access to any html control on page, you may use document.getElementById or its shortcut $get.
    If you do not know exact value of ClientID, then you may use <%=Control.ClientID%>.

    Below is example:

    <script type="text/javascript">
    function valueChanged(slider, eventArgs)
    {
     var tb1 = $get('<%=TextBox1.ClientID%>');
     if(tb1)
      tb1.value = eventArgs.get_newValue();
    }
    </script>

Children