C# – How to open another form in codebehind using javascript

asp.netc++

I have following code in button click
Response.Write("window.open('Contact.aspx')");

The above code is working.but if use

String s = "Contact.aspx";
            Response.Write("<script type=text/javascript>window.open('"+s+"')</script>");

The above code shows error as 'Too many literals'.Can anybody help to remove this error.

Best Solution

I believe you're missing the enclosing quotes around "text/javascript".

It should be:

String s = "Contact.aspx";
            Response.Write("<script type='text/javascript'>window.open('"+s+"')</script>");