Calling a javascript, syntax problem.

Posted on 2011-10-18
Last Modified: 2012-08-13
Hi, I'm trying to open a new window injecting a javascript in my C# codebehind, actually I've managed to open the new window, but there seems to be a problem with the string that C# turns into JS, because the page is blank and gives me the error "Server error in application "/".

Here's the code, it should be simple to sort this out.
This is the C# code to create the JS string:
js = "<SCRIPT LANGUAGE=\"JavaScript\">\n";
js += "\"/stampe/frame.aspx?pfid=RULLS\", \"\", \"width=300, height=100\")";
js += "</script>";

This is the content of the js variable just before I pass it to Response.Write(js):
"<SCRIPT LANGUAGE=\"JavaScript\">\\"/stampe/frame.aspx?pfid=RULLS\", \"\", \"width=300, height=100\")</script>"

Open in new window

Question by:DuskDweller
    LVL 13

    Accepted Solution

    try with the below code....
    js = "<SCRIPT LANGUAGE='JavaScript'>";
    js += "'/stampe/frame.aspx?pfid=RULLS','','width=300, height=100');";
    js += "</script>";

    Open in new window

    LVL 12

    Expert Comment


    Try below code:
    js = "<SCRIPT LANGUAGE=\"JavaScript\">\n";
    js += "\"stampe/frame.aspx?pfid=RULLS\", \"\", \"width=300, height=100\")";
    js += "</script>";

    Open in new window


    Author Closing Comment

    Thank you!

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Suggested Solutions

    ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
    Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    25 Experts available now in Live!

    Get 1:1 Help Now