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

Tags:

ASp.net 2.0 step by step Membership Provider Asp.net Interview Questions for 2 years or 3 years experianceasp net image uploadASP.net File HandlingRemoving aspnet runtime from IISAsp.net Convert String To Imagehow to open a blog websiteWhat is web garden in Asp.net?ASP net Write Text On Image C#.net and Vb.net programAsp.net Convert Image To Base64ASp.net RegisterClientScriptBlock

Author

My name is Satalaj, but people call me Sat. Here is my homepage: . I live in Pune, PN and work as a Software Engineer. I'm former MVP in ASP.net year 2010.
Disclaimer: Views or opinion expressed here are my personal research and it has nothing to do with my employer. You are free to use the code, ideas/hints in your projects. However, you should not copy and paste my original content to other web sites. Feel free to copy or extend the code.
If you want to fight with me, this website is not for you.
 

I'm Satalaj.