ASP. NET Method 1:
Response. write ("<script language = \" javascript \ "> window. open ('aaa. aspx ', 'new window, \ "toolbar = yes, location = no, directories = yes, status = yes, menubar = yes, resizable = yes, scrollbars = yes \"); </script> ");
In this way, the code is generated at the top of the page each time.
ASP. NET to open a new window method 2:
String strScript = "";
StrScript + = "<script language = \" javascript \ "> \ n ";
StrScript + = "window. open ('aaa. aspx ', 'new window, \ "toolbar = yes, location = no, directories = yes, status = yes, menubar = yes, resizable = yes, scrollbars = yes \"); \ n ";
StrScript + = "location.hrefw.'index.html ';";
StrScript + = "</script> ";
Bool B = (Page) System. Web. HttpContext. Current. Handler). IsStartupScriptRegistered ("PopUp ");
If (! B)
{
(Page) System. Web. HttpContext. Current. Handler). RegisterStartupScript ("PopUp", strScript );
}
In this way, JAVASCRIPT code is generated on the page.
Note: If the page jumps to another page with Response. Redirect after the JAVSSCRIPT statement is output, JAVASCRIPT will not appear.
The pop-up window and jump must be included in the JAVASCRIPT Statement at the same time,
I tested it. Do you have any different opinions ??
1. Response. Redirect ("XXX. aspx", true) -- go directly to the new page and replace the original window;
2. Response. Write ("<script> window. open (XXX. aspx ',' _ blank ') </script>") -- retain the original window and add a new page;
3. Response. Write ("<script> window. location = XXX. aspx '</script>") -- open a new page and replace the original window;
4. Server. Transfer ("XXX. aspx") -- open a new page;
5. Response. Write ("<script> window. showModelessDialog (XXX. aspx ') </script>") -- retain the original window and open a new window in the form of a dialog box;
6. Response. Write ("<script> window. showModalDialog (XXX. aspx ') </script>") -- open a new window in the dialog box. The original window is replaced;
From: http://blog.csdn.net/21aspnet/archive/2007/03/20/1535506.aspx