471,570 Members | 965 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,570 software developers and data experts.

forcing a new browser window

in my aspx app I am writing a stream that works fine but it replaces what is
in the client browser window. The code is as follows:
..
..
HttpContext.Current.Response.ClearHeaders()
HttpContext.Current.Response.ClearContent()
HttpContext.Current.Response.ContentType = "application/pdf"
Dim myBuffer(MyStream.Length) As Byte
MyStream.Read(myBuffer, 0, CType(MyStream.Length, Integer))
HttpContext.Current.Response.BinaryWrite(myBuffer)
HttpContext.Current.Response.End()

Is there any way I can force this to write to a new browser window?
TIA,
G
Nov 19 '05 #1
6 2955
You can only open a new browser window through client end script, server
code cannot and should not be allowed to do that.. That is, only user's
action on the client browser can bring up a new browser window. If server
code could do that, a bad guy would be easily write a simple page a attract
unsuspicious users and then keep popping up thousands of new windows until
the computer dies.

"G Dean Blake" <gb@nospam.com> wrote in message
news:ev**************@TK2MSFTNGP15.phx.gbl...
in my aspx app I am writing a stream that works fine but it replaces what is in the client browser window. The code is as follows:
.
.
HttpContext.Current.Response.ClearHeaders()
HttpContext.Current.Response.ClearContent()
HttpContext.Current.Response.ContentType = "application/pdf"
Dim myBuffer(MyStream.Length) As Byte
MyStream.Read(myBuffer, 0, CType(MyStream.Length, Integer))
HttpContext.Current.Response.BinaryWrite(myBuffer)
HttpContext.Current.Response.End()

Is there any way I can force this to write to a new browser window?
TIA,
G

Nov 19 '05 #2
Well,....
for instance you can set the Target property for any hyperlink to "_blank"
and it will trigger a new browser window when the hyperlink is executed.
Also, in the dataGrid property window you can set "_blank" in the target
dropdown and the same thing happens.

There is certainly no user action in either of these examples.

"Norman Yuan" <No*****@NotReal.not> wrote in message
news:OW****************@TK2MSFTNGP14.phx.gbl...
You can only open a new browser window through client end script, server
code cannot and should not be allowed to do that.. That is, only user's
action on the client browser can bring up a new browser window. If server
code could do that, a bad guy would be easily write a simple page a
attract
unsuspicious users and then keep popping up thousands of new windows until
the computer dies.

"G Dean Blake" <gb@nospam.com> wrote in message
news:ev**************@TK2MSFTNGP15.phx.gbl...
in my aspx app I am writing a stream that works fine but it replaces what

is
in the client browser window. The code is as follows:
.
.
HttpContext.Current.Response.ClearHeaders()
HttpContext.Current.Response.ClearContent()
HttpContext.Current.Response.ContentType = "application/pdf"
Dim myBuffer(MyStream.Length) As Byte
MyStream.Read(myBuffer, 0, CType(MyStream.Length, Integer))
HttpContext.Current.Response.BinaryWrite(myBuffer)
HttpContext.Current.Response.End()

Is there any way I can force this to write to a new browser window?
TIA,
G


Nov 19 '05 #3
Not sure what you mean by the target dropdown in the dataGrid property
window , but in the case of a hyperlink clicking the link is certainly a
user action. You can emit a javascript statement like window.open,
showModelDialog etc.

Eliyahu

"G Dean Blake" <gb@nospam.com> wrote in message
news:OE****************@TK2MSFTNGP10.phx.gbl...
Well,....
for instance you can set the Target property for any hyperlink to "_blank"
and it will trigger a new browser window when the hyperlink is executed.
Also, in the dataGrid property window you can set "_blank" in the target
dropdown and the same thing happens.

There is certainly no user action in either of these examples.

"Norman Yuan" <No*****@NotReal.not> wrote in message
news:OW****************@TK2MSFTNGP14.phx.gbl...
You can only open a new browser window through client end script, server
code cannot and should not be allowed to do that.. That is, only user's
action on the client browser can bring up a new browser window. If server code could do that, a bad guy would be easily write a simple page a
attract
unsuspicious users and then keep popping up thousands of new windows until the computer dies.

"G Dean Blake" <gb@nospam.com> wrote in message
news:ev**************@TK2MSFTNGP15.phx.gbl...
in my aspx app I am writing a stream that works fine but it replaces
what is
in the client browser window. The code is as follows:
.
.
HttpContext.Current.Response.ClearHeaders()
HttpContext.Current.Response.ClearContent()
HttpContext.Current.Response.ContentType = "application/pdf"
Dim myBuffer(MyStream.Length) As Byte
MyStream.Read(myBuffer, 0, CType(MyStream.Length, Integer))
HttpContext.Current.Response.BinaryWrite(myBuffer)
HttpContext.Current.Response.End()

Is there any way I can force this to write to a new browser window?
TIA,
G



Nov 19 '05 #4
I'm not up on Javascript. How would I emit a statement like Window.open?
For instance when doing a response.redirect to a page is there a way somehow
to open a new window?
Thanks,
G

"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:u0****************@TK2MSFTNGP11.phx.gbl...
Not sure what you mean by the target dropdown in the dataGrid property
window , but in the case of a hyperlink clicking the link is certainly a
user action. You can emit a javascript statement like window.open,
showModelDialog etc.

Eliyahu

"G Dean Blake" <gb@nospam.com> wrote in message
news:OE****************@TK2MSFTNGP10.phx.gbl...
Well,....
for instance you can set the Target property for any hyperlink to
"_blank"
and it will trigger a new browser window when the hyperlink is executed.
Also, in the dataGrid property window you can set "_blank" in the target
dropdown and the same thing happens.

There is certainly no user action in either of these examples.

"Norman Yuan" <No*****@NotReal.not> wrote in message
news:OW****************@TK2MSFTNGP14.phx.gbl...
> You can only open a new browser window through client end script,
> server
> code cannot and should not be allowed to do that.. That is, only user's
> action on the client browser can bring up a new browser window. If server > code could do that, a bad guy would be easily write a simple page a
> attract
> unsuspicious users and then keep popping up thousands of new windows until > the computer dies.
>
> "G Dean Blake" <gb@nospam.com> wrote in message
> news:ev**************@TK2MSFTNGP15.phx.gbl...
>> in my aspx app I am writing a stream that works fine but it replaces what > is
>> in the client browser window. The code is as follows:
>> .
>> .
>> HttpContext.Current.Response.ClearHeaders()
>> HttpContext.Current.Response.ClearContent()
>> HttpContext.Current.Response.ContentType = "application/pdf"
>> Dim myBuffer(MyStream.Length) As Byte
>> MyStream.Read(myBuffer, 0, CType(MyStream.Length, Integer))
>> HttpContext.Current.Response.BinaryWrite(myBuffer)
>> HttpContext.Current.Response.End()
>>
>> Is there any way I can force this to write to a new browser window?
>> TIA,
>> G
>>
>>
>
>



Nov 19 '05 #5
When the page is loaded the first time, you do:

private void Page_Load(....)
{
if (!Page.IsPostBack)
{
btn1.Attributes.Add("onlick",

"window.open('http://myServer//page1.aspx?param1=xxx&param2=yyyy',toolbar=0,
......); return false;");
}
else
{
...
}
}

after the page is loaded, if due to some user action, the URL for the new
window need to be changed, say, afer user clicking btn2, the underline
javascript for btn1 needs to be changed to open a different page, then you
need reattach the client javascript, so that btn1 now will open a different
page in new window:

private void btn2_Click(...)
{
try
{
btn1.Attributes.Remove("onclick")
}
catch{}

btn1.Attributes.Add("onlick",

"window.open('http://myServer//page2.aspx?param1=aaaa&param2=bbbb',toolbar=0
,.....); return false;");

}

Note, at the end of "window.open()", I add "return false;", so that clicking
btn1 will not cause unnecessary postback.

"G Dean Blake" <gb@nospam.com> wrote in message
news:OY**************@TK2MSFTNGP14.phx.gbl...
I'm not up on Javascript. How would I emit a statement like Window.open?
For instance when doing a response.redirect to a page is there a way somehow to open a new window?
Thanks,
G

"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:u0****************@TK2MSFTNGP11.phx.gbl...
Not sure what you mean by the target dropdown in the dataGrid property
window , but in the case of a hyperlink clicking the link is certainly a
user action. You can emit a javascript statement like window.open,
showModelDialog etc.

Eliyahu

"G Dean Blake" <gb@nospam.com> wrote in message
news:OE****************@TK2MSFTNGP10.phx.gbl...
Well,....
for instance you can set the Target property for any hyperlink to
"_blank"
and it will trigger a new browser window when the hyperlink is executed. Also, in the dataGrid property window you can set "_blank" in the target dropdown and the same thing happens.

There is certainly no user action in either of these examples.

"Norman Yuan" <No*****@NotReal.not> wrote in message
news:OW****************@TK2MSFTNGP14.phx.gbl...
> You can only open a new browser window through client end script,
> server
> code cannot and should not be allowed to do that.. That is, only user's > action on the client browser can bring up a new browser window. If

server
> code could do that, a bad guy would be easily write a simple page a
> attract
> unsuspicious users and then keep popping up thousands of new windows

until
> the computer dies.
>
> "G Dean Blake" <gb@nospam.com> wrote in message
> news:ev**************@TK2MSFTNGP15.phx.gbl...
>> in my aspx app I am writing a stream that works fine but it replaces

what
> is
>> in the client browser window. The code is as follows:
>> .
>> .
>> HttpContext.Current.Response.ClearHeaders()
>> HttpContext.Current.Response.ClearContent()
>> HttpContext.Current.Response.ContentType = "application/pdf"
>> Dim myBuffer(MyStream.Length) As Byte
>> MyStream.Read(myBuffer, 0, CType(MyStream.Length, Integer))
>> HttpContext.Current.Response.BinaryWrite(myBuffer)
>> HttpContext.Current.Response.End()
>>
>> Is there any way I can force this to write to a new browser window?
>> TIA,
>> G
>>
>>
>
>



Nov 19 '05 #6
If I understand this right when this page loads (lets call it mainpage) it
provides a button that will open another page (page1.aspx) to open in a new
window? I want the mainpage to open in a new window.
G
"Norman Yuan" <No*****@NotReal.not> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
When the page is loaded the first time, you do:

private void Page_Load(....)
{
if (!Page.IsPostBack)
{
btn1.Attributes.Add("onlick",

"window.open('http://myServer//page1.aspx?param1=xxx&param2=yyyy',toolbar=0,
.....); return false;");
}
else
{
...
}
}

after the page is loaded, if due to some user action, the URL for the new
window need to be changed, say, afer user clicking btn2, the underline
javascript for btn1 needs to be changed to open a different page, then you
need reattach the client javascript, so that btn1 now will open a
different
page in new window:

private void btn2_Click(...)
{
try
{
btn1.Attributes.Remove("onclick")
}
catch{}

btn1.Attributes.Add("onlick",

"window.open('http://myServer//page2.aspx?param1=aaaa&param2=bbbb',toolbar=0
,.....); return false;");

}

Note, at the end of "window.open()", I add "return false;", so that
clicking
btn1 will not cause unnecessary postback.

"G Dean Blake" <gb@nospam.com> wrote in message
news:OY**************@TK2MSFTNGP14.phx.gbl...
I'm not up on Javascript. How would I emit a statement like Window.open?
For instance when doing a response.redirect to a page is there a way

somehow
to open a new window?
Thanks,
G

"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:u0****************@TK2MSFTNGP11.phx.gbl...
> Not sure what you mean by the target dropdown in the dataGrid property
> window , but in the case of a hyperlink clicking the link is certainly
> a
> user action. You can emit a javascript statement like window.open,
> showModelDialog etc.
>
> Eliyahu
>
> "G Dean Blake" <gb@nospam.com> wrote in message
> news:OE****************@TK2MSFTNGP10.phx.gbl...
>> Well,....
>> for instance you can set the Target property for any hyperlink to
>> "_blank"
>> and it will trigger a new browser window when the hyperlink is executed. >> Also, in the dataGrid property window you can set "_blank" in the target >> dropdown and the same thing happens.
>>
>> There is certainly no user action in either of these examples.
>>
>> "Norman Yuan" <No*****@NotReal.not> wrote in message
>> news:OW****************@TK2MSFTNGP14.phx.gbl...
>> > You can only open a new browser window through client end script,
>> > server
>> > code cannot and should not be allowed to do that.. That is, only user's >> > action on the client browser can bring up a new browser window. If
> server
>> > code could do that, a bad guy would be easily write a simple page a
>> > attract
>> > unsuspicious users and then keep popping up thousands of new windows
> until
>> > the computer dies.
>> >
>> > "G Dean Blake" <gb@nospam.com> wrote in message
>> > news:ev**************@TK2MSFTNGP15.phx.gbl...
>> >> in my aspx app I am writing a stream that works fine but it
>> >> replaces
> what
>> > is
>> >> in the client browser window. The code is as follows:
>> >> .
>> >> .
>> >> HttpContext.Current.Response.ClearHeaders()
>> >> HttpContext.Current.Response.ClearContent()
>> >> HttpContext.Current.Response.ContentType =
>> >> "application/pdf"
>> >> Dim myBuffer(MyStream.Length) As Byte
>> >> MyStream.Read(myBuffer, 0, CType(MyStream.Length, Integer))
>> >> HttpContext.Current.Response.BinaryWrite(myBuffer)
>> >> HttpContext.Current.Response.End()
>> >>
>> >> Is there any way I can force this to write to a new browser window?
>> >> TIA,
>> >> G
>> >>
>> >>
>> >
>> >
>>
>>
>
>



Nov 19 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by shank | last post: by
5 posts views Thread by laredotornado | last post: by
3 posts views Thread by Tin Man | last post: by
reply views Thread by Jorge Ribeiro | last post: by
9 posts views Thread by Joel Byrd | last post: by
4 posts views Thread by ATS16805 | last post: by
2 posts views Thread by Greg Smith | last post: by
5 posts views Thread by Lord Zoltar | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by Vinnie | last post: by
reply views Thread by lumer26 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.