. Net window opening Methods

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.