Multiple methods for ASP. NET to open a new window

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> ");

This methodCodeEach time it is generated at the top of the page

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 ??
Multiple methods to open a new window in Asp.net
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>") -- the original window is retained, and a new page is added;
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;
------------------------

Category:. NET technology ASP. NET
----------------------------------------------------------------------

The following statement can be correctly executed:
Response. Write ("<script language = JavaScript> window. Open ('repair. aspx? UN = "+ usernumber +" & SID = "+ serviceid +" ') </SCRIPT> ");

But cannot be executed after parameters are added? As follows:

Response. Write ("<script language = JavaScript> window. Open ('repair. aspx? UN = "+ usernumber +" & SID = "+ serviceid +" ', 'toolbar = No, status = no') </SCRIPT> ");

----------------------------------------------------------------------

Response. Write ("<script language = JavaScript> window. Open ('repair. aspx? UN = "+ usernumber +" & SID = "+ serviceid +" ', '', 'toolbar = No, status = no') </SCRIPT> ");
Let's take a look!

--------------------------------------------------------

Replace comma with semicolon toolbar = no; scrollbars = No

--------------------------------------------------------

okay, thank you.
------------------------------------------
multiple methods for opening new windows in Asp.net (reprinted)
1. response. redirect ("XXX. aspx ", true) -- directly redirects to the new page, and the original window is replaced;
2. response. write (" ") -- the original window is retained, and a new page is added.
3. response. write (" ") -- open a new page and replace the original window.
4. server. transfer ("XXX. aspx ") -- open a new page;
5. response. write (" ") -- the original window is retained and a new window is opened in a dialog box.

-----------------------
<Script language = "JavaScript">
Function popupkind (xdm)
{
Url = "thisterm2add. aspx? Xdm = "+ xdm
HR = Window. showmodaldialog (URL, ''," dialogheight: 300px; dialogwidth: 300px; dialogleft: 60px; dialogtop: 30px; center: 1; Status: 1; Title: 0 ;")
}

</SCRIPT>

 

Related Article

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.