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

203
Views
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 answers
Answer question

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 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!