473,582 Members | 3,083 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Cur rent.Response.C learHeaders()
HttpContext.Cur rent.Response.C learContent()
HttpContext.Cur rent.Response.C ontentType = "applicatio n/pdf"
Dim myBuffer(MyStre am.Length) As Byte
MyStream.Read(m yBuffer, 0, CType(MyStream. Length, Integer))
HttpContext.Cur rent.Response.B inaryWrite(myBu ffer)
HttpContext.Cur rent.Response.E nd()

Is there any way I can force this to write to a new browser window?
TIA,
G
Nov 19 '05 #1
6 3056
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.co m> wrote in message
news:ev******** ******@TK2MSFTN GP15.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.Cur rent.Response.C learHeaders()
HttpContext.Cur rent.Response.C learContent()
HttpContext.Cur rent.Response.C ontentType = "applicatio n/pdf"
Dim myBuffer(MyStre am.Length) As Byte
MyStream.Read(m yBuffer, 0, CType(MyStream. Length, Integer))
HttpContext.Cur rent.Response.B inaryWrite(myBu ffer)
HttpContext.Cur rent.Response.E nd()

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*****@NotRea l.not> wrote in message
news:OW******** ********@TK2MSF TNGP14.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.co m> wrote in message
news:ev******** ******@TK2MSFTN GP15.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.Cur rent.Response.C learHeaders()
HttpContext.Cur rent.Response.C learContent()
HttpContext.Cur rent.Response.C ontentType = "applicatio n/pdf"
Dim myBuffer(MyStre am.Length) As Byte
MyStream.Read(m yBuffer, 0, CType(MyStream. Length, Integer))
HttpContext.Cur rent.Response.B inaryWrite(myBu ffer)
HttpContext.Cur rent.Response.E nd()

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.co m> wrote in message
news:OE******** ********@TK2MSF TNGP10.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*****@NotRea l.not> wrote in message
news:OW******** ********@TK2MSF TNGP14.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.co m> wrote in message
news:ev******** ******@TK2MSFTN GP15.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.Cur rent.Response.C learHeaders()
HttpContext.Cur rent.Response.C learContent()
HttpContext.Cur rent.Response.C ontentType = "applicatio n/pdf"
Dim myBuffer(MyStre am.Length) As Byte
MyStream.Read(m yBuffer, 0, CType(MyStream. Length, Integer))
HttpContext.Cur rent.Response.B inaryWrite(myBu ffer)
HttpContext.Cur rent.Response.E nd()

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.redire ct to a page is there a way somehow
to open a new window?
Thanks,
G

"Eliyahu Goldin" <re************ *@monarchmed.co m> wrote in message
news:u0******** ********@TK2MSF TNGP11.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.co m> wrote in message
news:OE******** ********@TK2MSF TNGP10.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*****@NotRea l.not> wrote in message
news:OW******** ********@TK2MSF TNGP14.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.co m> wrote in message
> news:ev******** ******@TK2MSFTN GP15.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.Cur rent.Response.C learHeaders()
>> HttpContext.Cur rent.Response.C learContent()
>> HttpContext.Cur rent.Response.C ontentType = "applicatio n/pdf"
>> Dim myBuffer(MyStre am.Length) As Byte
>> MyStream.Read(m yBuffer, 0, CType(MyStream. Length, Integer))
>> HttpContext.Cur rent.Response.B inaryWrite(myBu ffer)
>> HttpContext.Cur rent.Response.E nd()
>>
>> 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.IsPostBa ck)
{
btn1.Attributes .Add("onlick",

"window.open('h ttp://myServer//page1.aspx?para m1=xxx&param2=y yyy',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("onclic k")
}
catch{}

btn1.Attributes .Add("onlick",

"window.open('h ttp://myServer//page2.aspx?para m1=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.co m> wrote in message
news:OY******** ******@TK2MSFTN GP14.phx.gbl...
I'm not up on Javascript. How would I emit a statement like Window.open?
For instance when doing a response.redire ct to a page is there a way somehow to open a new window?
Thanks,
G

"Eliyahu Goldin" <re************ *@monarchmed.co m> wrote in message
news:u0******** ********@TK2MSF TNGP11.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.co m> wrote in message
news:OE******** ********@TK2MSF TNGP10.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*****@NotRea l.not> wrote in message
news:OW******** ********@TK2MSF TNGP14.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.co m> wrote in message
> news:ev******** ******@TK2MSFTN GP15.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.Cur rent.Response.C learHeaders()
>> HttpContext.Cur rent.Response.C learContent()
>> HttpContext.Cur rent.Response.C ontentType = "applicatio n/pdf"
>> Dim myBuffer(MyStre am.Length) As Byte
>> MyStream.Read(m yBuffer, 0, CType(MyStream. Length, Integer))
>> HttpContext.Cur rent.Response.B inaryWrite(myBu ffer)
>> HttpContext.Cur rent.Response.E nd()
>>
>> 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*****@NotRea l.not> wrote in message
news:%2******** **********@TK2M SFTNGP09.phx.gb l...
When the page is loaded the first time, you do:

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

"window.open('h ttp://myServer//page1.aspx?para m1=xxx&param2=y yyy',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("onclic k")
}
catch{}

btn1.Attributes .Add("onlick",

"window.open('h ttp://myServer//page2.aspx?para m1=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.co m> wrote in message
news:OY******** ******@TK2MSFTN GP14.phx.gbl...
I'm not up on Javascript. How would I emit a statement like Window.open?
For instance when doing a response.redire ct to a page is there a way

somehow
to open a new window?
Thanks,
G

"Eliyahu Goldin" <re************ *@monarchmed.co m> wrote in message
news:u0******** ********@TK2MSF TNGP11.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.co m> wrote in message
> news:OE******** ********@TK2MSF TNGP10.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*****@NotRea l.not> wrote in message
>> news:OW******** ********@TK2MSF TNGP14.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.co m> wrote in message
>> > news:ev******** ******@TK2MSFTN GP15.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.Cur rent.Response.C learHeaders()
>> >> HttpContext.Cur rent.Response.C learContent()
>> >> HttpContext.Cur rent.Response.C ontentType =
>> >> "applicatio n/pdf"
>> >> Dim myBuffer(MyStre am.Length) As Byte
>> >> MyStream.Read(m yBuffer, 0, CType(MyStream. Length, Integer))
>> >> HttpContext.Cur rent.Response.B inaryWrite(myBu ffer)
>> >> HttpContext.Cur rent.Response.E nd()
>> >>
>> >> 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
6250
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 rather have Excel receive the data. <% Response.contenttype = "application/vnd.ms-excel" %> <% Response.AddHeader "Content-Disposition", "filename=" &...
3
2470
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 popup contains a control panel that tells the main window what to display. Because we don't want to require that the user continually ALT-TAB to...
5
7464
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 automatically issue a browser refresh? Ideally, this solution should work for both IE and Firefox. Thanks, - Dave
3
1124
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 embed in the HTML to cause this? Maybe some javascript or something like that? Thanks in Advance, tin man
0
1083
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 send back to the client the requested file. To force, on client browser, the opening of the donwload window where is asked if the user wants
9
9637
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: if I put a really long word (like a web address) in the div, then it props the rest of the text open to the width of the word, and the text can't...
4
3651
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; a programming "what if..?". i'm not concerned w/ manipulating a browser (i.e. prefs., settings this URL, always view SSR, save), but rather...
2
2356
by: Greg Smith | last post by:
Is there a way to force the users browser to full screen? Any help is greatly appreciated.
5
10111
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 I've put in my button handler: //somewhere else in my code: private const int WM_VSCROLL = 277; // Vertical scroll .. ..
0
7886
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7809
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7920
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8183
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6569
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5366
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3809
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2312
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1147
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.