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

182
Views
How to pass values from C# to JavaScript using MVC?

I am working on a progress bar to update the user experience when we request data from the server. I have a Bootstrap progress bar that is updated it from JavaScript. I want pass the progress of the bar by passing the value from C# code. Here is what I have so far:

This is the HTML file:

<div class="progress">
    <asp:HiddenField ID="hdnfldVariable" runat="server" />
    <div class="progress-bar" role="progressbar" style="width: 0;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
</div>

This is the JavaScript File:

//Progress Bar
var progressBar = $('.progress-bar');
var progressNumber = "Here will go value from C# file";

setInterval(function () {
progressBar.css('width', progressNumber + '%');
progressBar.attr('aria-valuenow', progressNumber);
}, 100)

This is the C# value that I want to pass:

   public int progressBarPercentage;
   
   //listPrices.Count is List that updates when we request information from the server
   progressBarPercentage = listPrices.Count;

I try to use "<%=progressBarPercentage%>" but is not working, there is any other approach to this. Thank you

about 4 years ago · Juan Pablo Isaza
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!