window.open method

Posted by Venkat | Labels: , ,

Window.open method in asp.net - this is used in javascript to open a page on new window.
through this you can hide the menubar ,set the width and hieght of the popupwindow,status,toolbar,resizable etc., for this you can either set the value is 0 | 1 or yes | no

Example

window.open('http://msdn.microsoft.com', '', '');");

Suppose if you want to do on code behind check this code :

Here i have mentioned widht , height of the window ,top and left , menubar,toolbar,
location, resizable, scrollbars
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("<script language="javascript">");
sb.Append("window.open('popuop.aspx', 'CustomPopUp',");
sb.Append("'width=1020, height=750, left=0, top=0, menubar=no, toolbar=no, resizable=no, status=no, location=no, scrollbars=yes');<");
sb.Append("/script>");
Type t = this.GetType();
if (!Page.ClientScript.IsStartupScriptRegistered(t, "PopupScript"))
{
     Page.ClientScript.RegisterStartupScript(t, "PopupScript", sb.ToString());
 }


If you want to open a new window through in-line code try this.

   <img border="0" id="img_PopUp" onclick="window.open('../PopUp.aspx','custompopop','width=250,height=300,toolbar=no,menubar=no,statusbar=no,resizable=no,scrollbars=no,location=no, directories=no,copyhistory=no,left=250,top=250')" />
                                runat="server" src="../Images/Newwindow.png" style="width: 35px" />

Reference:


http://dotnetslackers.com/articles/aspnet/JavaScript_with_ASP_NET_2_0_Pages_Part1.aspx

PayOffers.in