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

219
Views
javascript cómo hacer que la página web obtenga la variable de sesión

Estoy tratando de usar una variable de sesión en javascript.

Desafortunadamente, probé varias sugerencias de publicaciones sin éxito.

Veo este ejemplo por todas partes.

 var userName = '<%= Session["UserName"] %>'

Sin embargo, eso no está funcionando, al menos para mí. Lo que estoy tratando de hacer es lo siguiente.

 var qrdataString = "<qr-code data=" + "XL" + ' <%= Session["style"] %>' + "></qr-code>"; document.getElementById("styleqr").innerHTML = qrdataString;

El uso de comillas simples donde aparecen arriba solo devuelve la cadena como

 <%=Session["xUID"]%> in the alert that I use to show me the returned value

El uso de comillas dobles me da un token inesperado: cadena literal o un identificador de token inesperado.

Gracias

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Después de perder el tiempo por un tiempo, y también tropezar con el siguiente artículo, he logrado que esto funcione.

 https://newbedev.com/get-current-session-value-in-javascript

RESULTADO COMPLETO

HTML

 Dim xstyle: xstyle = session("style") <div class="hr"> <input type="hidden" id="hdnSession" data-value= <%= xstyle %> /> </div>

JAVASCRIPT

 var hdnString= $("#hdnSession").data('value'); var qrdataString = "<qr-code data= " + hdnString + " ></qr-code>"; document.getElementById("qrcode").innerHTML = qrdataString;

HTML

 <div class="panel-body" id="qrcode"> javasctipt inserts the html here <!--qr-code data="test"></qr-code --> </div>
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!