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

205
Vistas
Built up string causing a syntax issue

I have a c# function that builds a string which in turn is used as a hyperlink to another page. However, with some strings with single quotes it is causing a javascript error as shown here:

enter image description here

I'm calling the javascript function in the code behind as so

linkFullMatch.NavigateUrl = "javascript:showFullMatches(" + sb.ToString() + ")";

the javascript is on the aspx function as so:

<script>
function showFullMatches(url) {
    window.open(url, "_blank", "height=344,width=1100,scrollbars=yes,resizable=yes,toolbar=no,location=no,status=no,menubar=no,left=580,top=194");
}

Any help would be greatly appreciated. Any string that doesn't have a single quote in works fine and the page link opens as requested.

Rob

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

0

You need to add an additional layer of quote marks to make the sb.ToString() value an JS string. Adjust your call like:

linkFullMatch.NavigateUrl = "javascript:showFullMatches('" + sb.ToString() + "')";

Note the additional ' marks.

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