Asp.net open new window

Asp.net open new window


Many times we require to open new window as popup with or without toolbar and statusbar.
Here are several ways to acheive it.



1. Open new window without status bar and toolbar

<div>

<asp:HyperLink ID="HyperLink1" runat="server"
      
 NavigateUrl
="javascript:window.open('http://www.bing.com','Title_of_your_window','statusbar=0,toolbar=0')">
      
1. Click here to popup window without statusbar and tool bar
</asp:HyperLink>

</div>

 

2.  Open new window with status bar

<asp:HyperLink ID="HyperLink1" runat="server"

NavigateUrl="javascript:window.
open('http://www.bing.com','Title_of_your_window','statusbar=1,toolbar=1')
">

2. Click here to popup window with statusbar and tool bar

</asp:HyperLink>


3. Control height and width of popup window

<asp:HyperLink ID="HyperLink1" runat="server"

NavigateUrl="javascript:window.
open('http://www.bing.com','Title_of_your_window','statusbar=1,toolbar=1,width=500,height=500')">

3. Click here to popup window with statusbar and tool bar

</asp:HyperLink>



ASP.NET Response.Redirect to new window

If you want to get the response in new window, you need to add an attribute target="_blank" in your form tag.
When page will do post back it will open response in new window


e.g. <form id="form1" target="_blank" runat
="server">

<asp:Button ID="Button1" runat="server" Text="Button" />

</form>

Above example will always open response in new window.

Using ASP.net Ajax Modal popup extender you can popin your controls as explained here
         http://www.asp.net/AJAX/AjaxControlToolkit/Samples/ModalPopup/ModalPopup.aspx
Video: http://www.asp.net/learn/ajax-videos/video-85.aspx

Satalaj

Currently rated 3.7 by 3 people

  • Currently 3.666667/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5