Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

117
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!