By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,190 Members | 1,056 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,190 IT Pros & Developers. It's quick & easy.

forcing a new browser window

P: n/a
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
Share this Question
Share on Google+
6 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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.