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

267
Views
Llamar a la función javascript desde el código de la página de afeitar

Teniendo en cuenta que tengo un código de barras de progreso de este sitio web https://www.geeksforgeeks.org/creating-progress-bar-using-javascript/ .

Tengo una página de afeitar con formato cshtml y el código de una página de afeitar con cshtml.cs . Supongamos que tengo Index.cshtml e Index.cshtml.cs .

Índice.cshtml

 <style> #Progress_Status { width: 50%; background-color: #ddd; } #myprogressBar { width: 0%; height: 35px; background-color: #4CAF50; text-align: center; line-height: 32px; color: black; } </style> <div id="Progress_Status"> <div id="myprogressBar"></div> </div> <script> function update(width) { var element = document.getElementById("myprogressBar"); var identity = setInterval(scene, 10); function scene() { if (width >= 100) { clearInterval(identity); } else { width++; element.style.width = width + '%'; } } } </script>

Índice.cshtml.cs

 public async void OnGet() { var progress = new Progress<int>(percent => { //Do something }); await Task.Run(() => TestFunction(progress)); } public void TestFunction(IProgress<int> progress) { int LoopCount = 1; while (LoopCount <= 100) { if (progress != null) { progress.Report(LoopCount); } LoopCount += 1; } }

Mi pregunta es... teniendo en cuenta que tengo una barra de progreso codificada con el enlace de muestra anterior. ¿Cómo puedo llamar a la función de actualización que existe en javascript en Index.cshtml.cs ?

El archivo de carga asíncrono habitual que puede actualizar la barra de progreso que existe en ASP.NET Core (stackoverflow u otro sitio web) no funciona ya que esta aplicación no implica la carga de archivos.

Si no se recomienda esta forma de llamar a la función javascript para actualizar la barra de progreso, ¿hay alguna forma alternativa de hacerlo?

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!