473,248 Members | 1,586 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,248 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 3028
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: shank | last post by:
I have the following code at the top of my page. Is there a way to force Excel to open the spreadsheet? Presently, it opens within the browser window. I know it can be saved etc., but I would...
3
by: Dave | last post by:
We are developing a web page that shows large graphics. To provide more screen space for the graphics, we allow the user to popup a window that places itself over the top part of the browser. This...
5
by: laredotornado | last post by:
Hello, When the user resizes the browser (either by clicking on the lower right or clicking the button at the upper left to maximize screen dimensions or not), how do I catch that event and then...
3
by: Tin Man | last post by:
I have an aspx page: myPage.aspx that I want to always display in a new brower window regardless of how it gets invoked i.e. hyperlink, response.redirect, server.transfer. Is there something I can...
0
by: Jorge Ribeiro | last post by:
Hello I've a .NET HTTP Handler that retrives binary files stored on a SQL Server database. Passing some ID to the HTTP Handler it reads from the database and constructs a HTTP message that...
9
by: Joel Byrd | last post by:
I've got a div whose width is specified as a percentage so that if you shrink the browser window, the div shrinks, and the text inside the div wraps around to accommadate this. The problem is:...
4
by: ATS16805 | last post by:
Hi. I wonder if it's possible to "force" a browser to "switch to SSR mode" for any given document. Specifically, I'm looking for a solution, not to a User Agent issue (i think), but a coding idea;...
2
by: Greg Smith | last post by:
Is there a way to force the users browser to full screen? Any help is greatly appreciated.
5
by: Lord Zoltar | last post by:
Hello, I'm trying to force a listView to scroll to some location when a certain button is clicked on. I've found that the SendMessage function seems to be the choice way of doing it. Here's what...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.