Wrox Programmer Forums
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 14th, 2007, 10:10 AM
Authorized User
 
Join Date: Nov 2006
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default Open new browser window

Can someone point me to some code that will open a new browser window from my website via a button.

On my website I select a menu option that opens a page with a button on it. When I select the button I don't want the new page to be loaded in the current page, but into a separate new page so that when I close this new page I can continue on the current page which has the button on.

Thanks

Andy M
 
Old February 14th, 2007, 10:32 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Either add this javascript code through Attributes.Add(), in the handler for the button use Response.Write() to send it back to the browser or use an html button and wire up this code for the onClick event.

window.open();

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
 
Old February 22nd, 2007, 06:03 AM
Authorized User
 
Join Date: Nov 2006
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the reply. After some trial and error I have finally worked out what it meant and will share it with anyone else who might what to do the same thing :-


Method 1.
Add this javascript code through Attributes.Add(), in the handler for the button use Response.Write() to send it back to the browser :-

In this example I have a button (Button2) to open a new window for my photo album.
In the code behind :-

 Partial Class DefaultVb
     Inherits System.Web.UI.Page

     Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
         Response.Write(" ")
     End Sub

     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
         Button2.Attributes.Add("onclick", "window.open('http://www.braybrookefc.co.uk/Match/PhotoAlbumVb.aspx', 'popupwindow', 'width=800,height=600,scrollbars,resizable')")
         'Button2.Style.Add("background-color", "red")
     End Sub
 End Class

In the .aspx file
    <asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Goto Album" Font-Bold="True" ForeColor="Red" BorderColor="Blue" BorderStyle="Outset" BorderWidth="2px" BackColor="White" />

Method 2.
Use an html button and wire up this code for the onClick event :-

In this example, I wanted to open a new window when a link to another website is selected.

      <asp:Hyperlink ID="Hyperlink1" Runat="server"
          NavigateUrl="http://www.eastberkshirefootballleague.co.uk/"
          onclick="window.open (this.href, 'popupwindow',
          'width=800,height=600,scrollbars,resizable');
          return false;">East Berks Football League Website
      </asp:Hyperlink>

I hope this can help.

Andy M






Similar Threads
Thread Thread Starter Forum Replies Last Post
open new browser window rocksbhavesh ASP.NET 1.0 and 1.1 Basics 2 July 19th, 2007 07:34 AM
browser wouldn't open b00k12 Visual Basic 2005 Basics 0 July 11th, 2007 12:57 AM
File Browser window Figgis Access 2 November 20th, 2005 01:49 PM
Launch default browser in a new browser window haiying Beginning VB 6 1 August 30th, 2005 05:48 PM
How to open window browser in ASP? Andraw Classic ASP Basics 6 March 31st, 2005 07:31 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.