Using C# code behind to open a new Internet Explorer window

I'm using the Response object to stream pdf document to the browser when a user hits a particular button on a page. This is working correctly, however the pdf opens in the same browser window. How do I open a new (second) browser window and stream the output to this new window?

Thanks!

-1
ilfc
5/10/2005 4:46:48 PM
asp.net.getting-started 91979 articles. 2 followers. Follow

6 Replies
1306 Views

Similar Articles

[PageSpeed] 28

You have to use client side code (javascript) to open a new IE window. You can call the javascript after server side code executed.
This posting is provided "AS IS" with no warranties, and confers no rights.
-1
JimmyM
5/10/2005 5:02:39 PM

Hi,

first check out this code sample:

Open a popup window after a button click

After reading your post I saw that you're trying to open a pdf document in a browser window. Personally I like it more that a pdf, or any other type of document, opens in the dedicated program instead of in the dedicated program "embedded" in an internet explorer window. You can do it when using content-disposition.

http://aspalliance.com/259

Grz, Kris.


Read my blog. Handy Firefox plugins for web developers.


Workaround for non working Mark as answer buttons.
-1
XIII
5/10/2005 5:35:31 PM

Thanks. I added the following code to my Page_Load event:

this.bPrintDetail.Attributes.Add("onclick","javascript:window.open();");

This does cause a new window to be opened but how do I get a handle to this window to stream the data to? Right now, although the new window opens, the pdf data is still streamed to the original window.

Thanks!

-1
ilfc
5/10/2005 5:38:18 PM

Thanks Kris,

The link you provided was very helpful. How would I extend your sample to get the handle to the open window so I can stream pdf data to it?

1
ilfc
5/10/2005 5:49:23 PM
 ilfc wrote:

Thanks. I added the following code to my Page_Load event:

this.bPrintDetail.Attributes.Add("onclick","javascript:window.open();");

This does cause a new window to be opened but how do I get a handle to this window to stream the data to? Right now, although the new window opens, the pdf data is still streamed to the original window.

Thanks!

You may need to stream the pdf in a new aspx file and dispay that in the new window.


This posting is provided "AS IS" with no warranties, and confers no rights.
1
JimmyM
5/10/2005 7:03:59 PM

 ilfc wrote:
The link you provided was very helpful. How would I extend your sample to get the handle to the open window so I can stream pdf data to it?

Actually I wouldn't use the new browser window trick but the content-disposition one. I tried it at my former company and worked out just fine. Especially with pdf documents. I don't have the code but check out the aspalliance.com link I provided in my earlier post or google on content-disposition.

Grz, Kris.


Read my blog. Handy Firefox plugins for web developers.


Workaround for non working Mark as answer buttons.
-1
XIII
5/10/2005 9:19:09 PM
Reply:

Similar Artilces:

opening new window from code behind using javascript
Hello,I am trying to open new window when i click on a button using javascript Page.ClientScript.RegisterStartupScript(this.GetType(), "openwindow", "window.open('WebForm2.aspx','','height=200,width=300');", true);this is the code i am using.But the problem is it postsback whole page.Can some body tell me how i can open new window without posting back the page.ThanksVinod   Hi Vinod,Do you use a scriptmanager on your page?If so, then you should use the RegisterStartupScript method of the ScriptManager class (= ScriptManager.RegisterStar...

Opening a new browswer window using code behind
I have an ASP.NET application with the code behind written in C#. I'm trying to figure out how to open a new browser window when a user selects a menu option. Right now I have the command: Response.Redirect("documents/Employee.pdf"); The problem is that this opens the pdf in the same browser window when, instead, I would like to open the pdf in a new browser window. How can I do this? Thanks! I am not sure what you mean by 'selects a menu option' - so I am presuming that you mean a button.You cannot open a new window from the code behind as it is server side only. You can, however, att...

How to get a new window to open, with picture, using C# and Request.QueryString
Hi guys, I'am using the My Webpage Starter Kit. In this, I'a using the gallery to show my pics. At default, when the thumbnail is clicked it goes to the details view with a bigger picture. However I do not want to go to the second page of the gallery, I want a new picture window to pop up with the big picture as uploaded to the server.   The code: <asp:DataList runat="server" ID="lstGallery" DataKeyField="Guid" OnItemCommand="lstGallery_ItemCommand" SkinID="gallery"> <ItemTemplate> <asp:LinkButton runat=&qu...

Opening New Window without Title bar & Frames of Internet explorer, & want to set opacity as 50% to internet explorer.
Hi, All This post is related to opening new window  as pop up window with the help of javascript. Syntax is like: -  window.open('url to open','window name','attribute1,attribute2') where : - attribute1,attribute2' As with alot of other things, we have a choice of attributes you can adjust.we can use these attributes to open window as we want.now my problem start...in my case :- i dont want title bar which can be done by setting full screen property to true; which doesnt solve my problem, i want my window size as (200,200...

How to open a window PB in new window of Internet Explorer?
Hi, How to open a window PB in new window of Internet Explorer? ...

How to use window.dialogarguments properties to get the information passed in window.showmodaldialog in the code behind of the modal window page
How to use window.dialogarguments properties to get the information passed in window.showmodaldialog in the code behind of the modal window pagelaks See if this helps: http://msdn2.microsoft.com/en-us/library/ms533723(VS.85).aspxMark replies as answers if they helped you solve the problem. I saw that..But i want to use it in my code behind.    laks window.dialogArguements is available in client-side JavaScript only.Mark replies as answers if they helped you solve the problem. Any option to have the same functionality of showModalDialog of javascript in asp.net?....

How to use window.dialogarguments properties to get the information passed in window.showmodaldialog in the code behind of the modal window page
How to use window.dialogarguments properties to get the information passed in window.showmodaldialog in the code behind of the modal window page Hi ashutosh, Here is an article that explains the use of the window.dialogArguments method. In the article is even an example that combines that property with the window.showModalDialog method. The article: http://msdn2.microsoft.com/en-us/library/ms533723.aspx Caution: You have to remember that those methods of the window class are case sensitive. window.showmodaldialog is not the same as window.showModalDialog ! Hope this helps!WimPlease re...

use VB.NET and C#.NET code in the same C#.NET project
All-- Here is a sample that is "off the beaten path", (at least for me). Is it possible, in an ASP.NET application, using the code-behind page building technique, to have both pages written in VB.NET and pages written C#.NET?At http://www.WebLogicArts.com/DemoList.aspx there is a sample that shows that, (contrary to popular belief), it IS possible to mix ASP.NET pages built with C#.NET with ASP.NET pages built with VB.NET in the same VS.NET 2003 project. Note that this is just a "fun" sample to see if it can be done and I do not recommend this practice as a "standard" way of develo...

OPEN NEW WINDOW USING window.open
Hi, can any eagle eyed geniuses spot what I'm doing wrong here? It's doing my nut! I'm simply trying to call a new page in a new window that I want to control the size, etc. I've tried two different ways - one from within my code behind and the other triggered by a LinkButton command action. Both do absolutely nothing. Please help... Private Sub InfoClick1(ByVal pSiteCode) Response.Write("<script>window.open('siteinfo.aspx?sitecode='" & pSiteCode & "','Info','left=20,top=20,height=500,width=850,toolbar=no,status=no,resizable=1,scrollbars=no')</script>") End Sub +...

Get rid of "Windows Internet Explorer" in title of new IE window..
Does anyone know how that is done :) ...Page.Title only adds to the title of the window  NuwandaYou learn from experience, everything else is just information.  get rid of this post maybe? :)You learn from experience, everything else is just information. Nuwanda: Does anyone know how that is done :) ...Page.Title only adds to the title of the window Nuwanda Hi Nuwand, As far as I know, it is not possible to achieve this for the reason the title 'Microsoft Internet Explorer' is set in the Internet Explorer itself and a web page has no permission to chang...

window.open in c# using RegisterClientScriptBlock opens window in minimized
Hello Friends I am developing web application using Win XP, IIS, C#, Sql Server etc. Now I have one button on to my web page when user click it, i do some operation on server side and then opens into a new window. So I have opened the window by using c#  and by RegisterClientScriptBlock.... But when it opens, it opens properly but get minimize to the taskbar. I wanted it to remain open or restore, So if anybody have an idea, Please let me know soon. My code to open new window..string script = String.Format("window.open('ChildWindow.aspx',null,'height=550, ...

Open a new window from C# code
I support a website for a non-profit theatre group in Atlanta at www.synchrotheatre.com.  When a visitor wants to buy tickets, I open a new window with an SSL connection to my ticketing app; all works fine. My new task is to allow users the option of entering a promo code on the Buy Tickets page to receive a discount ticket price.  My current thought is to do something like the following (see http://test.synchrotheatre.com/tickets/buytickets.aspx for a partial implementation):       If you have a promo code, enter it and click 'Go':   ...

Sending SMS using vb.net or C#.net using vb.net or c#.net
Hi  My requirement is I hav one csv file with these fields id,mobilenum,messgae,status.intiallu staus is 0. once i read the all fileds and take that mobile number.using tat mobile number  i need to send sms .after sending sms i shuld change status as 1 How to send sms thru coding (please dont provide any links.if it is provide also please give working links becox i checked codeproject .i didnt get any nice link. and also provide the how to update the status field im csv file   Thank ssandhya   To send SMS, you need some third party SMS providers. if you consul...

Opening a new window from the code behind
Hi, On my web page I have a button which runs some code to update values. At the start of this code in the code behind I'd like to open another web page and another at the end of the updates but I can't work out how I do that. I've gota javascript window.open statement on my client side code, do I need to do something similar on the code behind ? Thanks for any help.  hi, I assume someone clicks on the button on page 1? Button1.Attributes.Add("onclick", "window.open('Page2.aspx','popWin','width=300px,height=200px');"...

Web resources about - Using C# code behind to open a new Internet Explorer window - asp.net.getting-started

Internet - Wikipedia, the free encyclopedia
The Internet is a global system of interconnected computer networks that use the standard Internet protocol suite (TCP/IP) to link several billion ...

Internet - Wikipedia, the free encyclopedia
The Internet is a global system of interconnected computer networks that use the standard Internet protocol suite (TCP/IP) to link several billion ...

Internet - Wikipedia, the free encyclopedia
... government networks of local to global scope, linked by a broad array of electronic, wireless, and optical networking technologies. The Internet ...

Internets - Wikipedia, the free encyclopedia
" Internets ", also known as " The Internets ", is a Bushism -turned- catchphrase used humorously to portray the speaker as ignorant about the ...

Internet Evolution - The Macrosite for News, Analysis, and Opinion about the Future of the Internet
The next big leap forward in the history of the Internet is happening now: Internet Evolution (www.internetevolution.com) is a Web 2.0 online ...

Microsoft is finally letting Internet Explorer 8, 9 and 10 die next week
If you're still using any version of Internet Explorer other than IE11 , it's time to upgrade. Microsoft is ending support for Internet Explorer ...

This is what the internet looked like in 1996, back when it only had 10 million users
Twenty-one years ago, in 1995, the Internet only had 10 million active users. Only 35 million people used email. To most Americans, the Internet ...

Is this the worst Internet law ever?
Donald Trump’s suggestion to ask for Bill Gates’ help in “closing that Internet up” as a way to combat terrorism was widely derided, as was his ...

Microsoft Ends An Era: Support For Internet Explorer 8, 9, And 10 Stops Next Week
The end is nigh: as of Tuesday, January 12, Microsoft will issue its final support patch for versions 8, 9, and 10 of its Internet Explorer browser, ...

This Sexy Photo Of Ronda Rousey Is Going To Break The Internet
This Sexy Photo Of Ronda Rousey Is Going To Break The Internet

Resources last updated: 1/7/2016 7:18:04 PM