views:

439

answers:

2

Hi there,

I'm trying to pop a window up, from inside a procedure running in SharePoint. I need to pass a parameter to the URL, and have been trying to run the following, however, the popup never pops up.

string sURL="http://myserver/mypage.aspx?param1=abc";
Response.Write("script LANGUAGE=\"Javascript\">\n");
Response.Write("window.open(\""+sUrl +"\", \"\", \"width=300, height=100\")");
Response.Write("<//script");

Can you help ?

Cheers

Nick

+3  A: 

A couple of things:

  • Your opening script tag is missing a < (opening angle bracket.).
  • You don't need the \n at the end of that line.
  • Your window.open command should have a ; at the end. (For completeness.)
  • Your closing script tag does not need a double //
  • Your closing script tag needs a closing > bracket. (Thanks OedipusPrime)

I believe that should fix it, it was probably the opening angle bracket which was the problem. However you should probably use ClientScript.RegisterStartupScript instead.

Bravax
A: 

You should take a look at this MSDN article.

As the above poster stated, the script you're attempting to write out has various errors (you're also missing a > in the closing script tag), but more importantly you should be using the ASP.Net object model for injecting the Javascript on the page.

OedipusPrime