Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

204
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda