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

192
Views
Variable in the JavaScript in C#
ClientScript.RegisterStartupScript(
    Page.GetType(),
    "INFORMATION",
    @"PopupMessage(""INFORMATION"", ""Data was created successfully"", false);",
    true);

The code above show the JavaScript code in C# code behind

What I want to do is add the variable to the message

but I used this code which does not work:

ClientScript.RegisterStartupScript(
    Page.GetType(),
    "INFORMATION",
    @"PopupMessage(""INFORMATION"", """+Data+" was created successfully"", false);",
    true);

It throws error:

Error CS1501 No overload for method 'RegisterStartupScript' takes 5 arguments

Does someone know how to make it work?

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

0

This string literal is a syntax error:

" was created successfully"", false);"

One of the things the verbatim identifier does for a string is change the way double-quotes are interpreted. Without it, double-quotes need to be escaped. But with it, escaping doesn't work (because it's a verbatim string) so a special consideration needs to be made for double-quotes. To add them to a string you need to "double" them.

This is why your other string literal works as expected:

@"PopupMessage(""INFORMATION"", """

To achieve the same thing in the failing string literal, use the verbatim identifier again:

@" was created successfully"", false);"
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!