When the following code is run:
Response.Write("window.open('BugSummaryForPrint.aspx?prjId=" + prjId + "&prjName=" + prjName','_blank')");
I get this error:
Newline in constant
Help!
When the following code is run:
Response.Write("window.open('BugSummaryForPrint.aspx?prjId=" + prjId + "&prjName=" + prjName','_blank')");
I get this error:
Newline in constant
Help!
As horrid of a "question" as this is, I feel helpful tonight. You were missing a couple characters (+ "
) in your code, after you appended prjName
.
Response.Write("window.open('BugSummaryForPrint.aspx?prjId=" + prjId + "&prjName=" + prjName + "','_blank')");
If genuinely C# (and the fact that its a redirect to a .aspx suggests that it probably is) then you can make your life a bit easier as follows:
string resp = String.Format(
"window.open('BugSummaryForPrint.aspx?prjId={0}&prjName={1}','_blank')",
prjId,
prjName
);
Response.Write(resp);
You could as easily do it all in one line (do the String.Format inline with the Response.Write) I've just split it a bit for clarity.
String.Format (and other places where you can use format strings like .AppendFormat in stringbuilders) is an oft overlooked tool.