Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

118
Vistas
Cannot access html value set by script from backend

I have an html input tag with runat="server" and id. A jquery function (slider) sets the value of the input field. However, I am not able to access the value of the input control on the server side. How do I get the value of the input control?

jquery slider function snippet:

    var num = $('#body_num1')
    $('#slider').slider({
     min:0,
     max:100, 
     slide: function(event, ui){
        num.val(ui.values[0]);
     }
    });

the asp.net code:

    <input type="text" id="num1" readonly runat="server"/>

when button doSomething is cliked (it should access num1's value):

    Protected Sub btn_doSomething_ServerClick(sender As Object, e As EventArgs)
      Dim num1_input As String = num1.Value
      System.Diagnostics.Debug.Writeline(num1_input)
    End Sub

I get the JIT Compiler encountered an internal limitation error.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Try this:

        <div id="MyTestSlider" style="width:30%">
        </div>

        <asp:HiddenField ID="MySlideValue" runat="server" ClientIDMode="Static"/>
        <asp:TextBox ID="TextBox1" runat="server" ClientIDMode="Static"></asp:TextBox>
                    
        <asp:Button ID="Button1" runat="server" Text="Button" />

        
        <script>

            $('#MyTestSlider').slider({
                min: 0,
                max: 100,
                step: 5,
                slide: function (e) {
                    slideValue = $('#MyTestSlider').slider("value")
                    $('#TextBox1').val(slideValue)
                    $('#MySlideValue').val(slideValue)

                }
                });

        </script>

And thus code behind is this:

Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

    Debug.Print("Slider value = " & MySlideValue.Value)
    Debug.Print("Slider value in text box = " & TextBox1.Text)


End Sub

So I have both a hidden field, and a text box. You of course don't need both.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda