473,407 Members | 2,546 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,407 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 3039
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.