467,925 Members | 1,660 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,925 developers. It's quick & easy.

using window.open javascript in asp.net

I am currently using response.redirect in a aspx to go to a web page.
What I want is to open the page in a new window. My dotnet code is as
follows:

Dim sFileName as string = "/TempReports/tempReport.pdf"
response.redirect(sFileName)

This opens in the same frame and I want to use something like
window.open so I can force a new page and control the size of the
window, etc.... One thing I thought about is calling a javascript
function from within a linkbutton. I don't want to use the
attributes.add because the link button already has code.

I have tried:

Dim scriptString As String = "<script language='javascript'>
{window.open(" & sFileName & ");} </script>"

Response.Write(scriptString)

but the "<script language=javascript></script>" doesn't come across as
a string in my code, it actually comes across as an actual script tag
even though it is in quotes.
I have tried:

Response.Write("<META HTTP-EQUIV=""REFRESH"" Content=""0;URL=" &
sFileName & """ target=""_blank"">")

to at least get it to open in a new window but I can't get it to work.
Even though I have the target=""_blank"" it still opens in the same
frame.

Any suggestions?
Nov 18 '05 #1
  • viewed: 9573
Share:
3 Replies
I think you have to lose the braces { }, and register the script.

Dim scriptString As String = "<script language='JavaScript'>
window.open('/TempReports/tempReport.pdf');</script>"

RegisterStartupScript("whatever", scriptString)

I assume it will work if you drop your sFileName var in there, as well. Worth a try, anyway.

George
"Stephen Witter" <sw*****@enpathmed.com> wrote in message
news:7e**************************@posting.google.c om...
I am currently using response.redirect in a aspx to go to a web page.
What I want is to open the page in a new window. My dotnet code is as
follows:

Dim sFileName as string = "/TempReports/tempReport.pdf"
response.redirect(sFileName)

This opens in the same frame and I want to use something like
window.open so I can force a new page and control the size of the
window, etc.... One thing I thought about is calling a javascript
function from within a linkbutton. I don't want to use the
attributes.add because the link button already has code.

I have tried:

Dim scriptString As String = "<script language='javascript'>
{window.open(" & sFileName & ");} </script>"

Response.Write(scriptString)

but the "<script language=javascript></script>" doesn't come across as
a string in my code, it actually comes across as an actual script tag
even though it is in quotes.
I have tried:

Response.Write("<META HTTP-EQUIV=""REFRESH"" Content=""0;URL=" &
sFileName & """ target=""_blank"">")

to at least get it to open in a new window but I can't get it to work.
Even though I have the target=""_blank"" it still opens in the same
frame.

Any suggestions?


Nov 18 '05 #2
Thanks for your reply. The questions I posted was a process that was
a second choice for me because I couldn't do something I wanted to do
in a web form. As it turns out the reason I couldn't do it the way I
wanted to had to do with misspelling an event name. The event in
dotnet was OnSelectedIndexChanged. I was spelling it
OnSelectedIndexChange.

Funny, it took me almost three weeks to catch that I didn't have a "d"
on the end of my event.

shesh...

"George" <------@----.---> wrote in message news:<fL*********************@bgtnsc04-news.ops.worldnet.att.net>...
I think you have to lose the braces { }, and register the script.

Dim scriptString As String = "<script language='JavaScript'>
window.open('/TempReports/tempReport.pdf');</script>"

RegisterStartupScript("whatever", scriptString)

I assume it will work if you drop your sFileName var in there, as well. Worth a try, anyway.

George
"Stephen Witter" <sw*****@enpathmed.com> wrote in message
news:7e**************************@posting.google.c om...
I am currently using response.redirect in a aspx to go to a web page.
What I want is to open the page in a new window. My dotnet code is as
follows:

Dim sFileName as string = "/TempReports/tempReport.pdf"
response.redirect(sFileName)

This opens in the same frame and I want to use something like
window.open so I can force a new page and control the size of the
window, etc.... One thing I thought about is calling a javascript
function from within a linkbutton. I don't want to use the
attributes.add because the link button already has code.

I have tried:

Dim scriptString As String = "<script language='javascript'>
{window.open(" & sFileName & ");} </script>"

Response.Write(scriptString)

but the "<script language=javascript></script>" doesn't come across as
a string in my code, it actually comes across as an actual script tag
even though it is in quotes.
I have tried:

Response.Write("<META HTTP-EQUIV=""REFRESH"" Content=""0;URL=" &
sFileName & """ target=""_blank"">")

to at least get it to open in a new window but I can't get it to work.
Even though I have the target=""_blank"" it still opens in the same
frame.

Any suggestions?

Nov 18 '05 #3
Been there. Done that. ;-)
"Stephen Witter" <sw*****@enpathmed.com> wrote in message
news:7e**************************@posting.google.c om...
Thanks for your reply. The questions I posted was a process that was
a second choice for me because I couldn't do something I wanted to do
in a web form. As it turns out the reason I couldn't do it the way I
wanted to had to do with misspelling an event name. The event in
dotnet was OnSelectedIndexChanged. I was spelling it
OnSelectedIndexChange.

Funny, it took me almost three weeks to catch that I didn't have a "d"
on the end of my event.

shesh...

"George" <------@----.---> wrote in message

news:<fL*********************@bgtnsc04-news.ops.worldnet.att.net>...
I think you have to lose the braces { }, and register the script.

Dim scriptString As String = "<script language='JavaScript'>
window.open('/TempReports/tempReport.pdf');</script>"

RegisterStartupScript("whatever", scriptString)

I assume it will work if you drop your sFileName var in there, as well. Worth a try, anyway.

George
"Stephen Witter" <sw*****@enpathmed.com> wrote in message
news:7e**************************@posting.google.c om...
I am currently using response.redirect in a aspx to go to a web page.
What I want is to open the page in a new window. My dotnet code is as
follows:

Dim sFileName as string = "/TempReports/tempReport.pdf"
response.redirect(sFileName)

This opens in the same frame and I want to use something like
window.open so I can force a new page and control the size of the
window, etc.... One thing I thought about is calling a javascript
function from within a linkbutton. I don't want to use the
attributes.add because the link button already has code.

I have tried:

Dim scriptString As String = "<script language='javascript'>
{window.open(" & sFileName & ");} </script>"

Response.Write(scriptString)

but the "<script language=javascript></script>" doesn't come across as
a string in my code, it actually comes across as an actual script tag
even though it is in quotes.
I have tried:

Response.Write("<META HTTP-EQUIV=""REFRESH"" Content=""0;URL=" &
sFileName & """ target=""_blank"">")

to at least get it to open in a new window but I can't get it to work.
Even though I have the target=""_blank"" it still opens in the same
frame.

Any suggestions?

Nov 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by Raphael Gluck | last post: by
24 posts views Thread by jonathon | last post: by
6 posts views Thread by Erik Steffl | last post: by
7 posts views Thread by Bill H | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.