Using Response.Write in code-behind page to popup javascript

N

Nevyn Twyll

Is there any way I can use a code-behind event (like a btn_Click event)
to write some javascript into the Response?

I was thinking of using Response.Write() to write the following code into
the response:

window.open("mynextpage.aspx","_blank", "height=300, width=450,
left=100, top=100, " + "location=no, menubar=no, resizable=no, " +
"scrollbars=no, titlebar=no, toolbar=no", true);


Any idea how I'd do that?

Thanks!
 
K

Kevin Spencer

string _Script = "window.open(\"mynextpage.aspx\",\"_blank\", \"height=300,
width=450, left=100, top=100, location=no, menubar=no, resizable=no,
scrollbars=no, titlebar=no, toolbar=no\", true);";
if (!Page.IsStartupScriptRegistered("MyScript"))
Page.RegisterStartupScript("MyScript", _Script);

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
N

Nevyn Twyll

And will that then run only once?
Or will it keep running every time a postback happens?
 
K

Kevin Spencer

It will run where you use it.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
N

Nevyn Twyll

I tried this code, and it just doesn't seem to run. I even tried just
having it open a blank window, or do an alert, but it doesn't seem to do
anything. I also tried prefixing it with
javascript:
and that didn't seem to work, either.

Help?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top