This article describes the ASP.net open a new page without closing the original page instance code, the need for friends can refer to, I hope you have some help
copy code code as follows:
respose.write ("<script language= ' JavaScript ' >window.open (' + URL + ');</script>"); (Open simple window):
respose.write ("<script language= ' JavaScript ' >window.open" + URL + "', ', ', ' RESIZABLE=1,SCR Ollbars=0,status=1,menubar=no,toolbar=no,location=no, Menu=no ');</script> ");
1. Response.Redirect ("xxx.aspx", true)--directly to the new page, the original window is replaced;
2. Response.Write ("<script>window.open" (' xxx.aspx ', ' _blank ') </script> ")--the original window is reserved, another new page is added;
3. Response.Write ("<script>window.location= ' xxx.aspx ' </script>")--Opens the new page, replaces the original window;
4. Server.Transfer ("xxx.aspx")--open a new page;
5. Response.Write ("<script>window.showmodelessdialog (' xxx.aspx ') </script>")--the original window is reserved to open a new window in the form of a dialog box;
6. Response.Write ("<script>window.showmodeldialog (' xxx.aspx ') </script>")--dialog form opens a new window, the original window is replaced;
You can also write your own method:
Copy Code code as follows:
public static void ShowMessage (System.Web.UI.Page Page, string msg)
{
page. Clientscript.registerclientscriptblock (page. GetType (), "a", "alert ('" + MSG.) ToString () + "');", true);
}
The time of the call:
ShowMessage (This, "message to display");
Here's the whole class code you can pick with
Copy Code code as follows:
Using System;
using System.Collections.Generic;
using System.Text;
namespace Worklogic
{
///<summary>
///Displays the message prompt dialog box.
///</summary>
public class MessageBox
{
private MessageBox ()
{
}
///<summary>
///Displays the message prompt dialog box
///</summary>
///<param name= "page" > current page pointer, generally this</param>
<param name= "MSG" > Hint info </param>
public static void ShowMessage (System.Web.UI.Page Page, string msg)
{
//page. RegisterStartupScript ("message", "Alert" + MSG.) ToString () + "');");
page. Clientscript.registerclientscriptblock (page. GetType (), "a", "alert ('" + MSG.) ToString () + "');", true);
}
public static void ShowMessage (System.Web.UI.UserControl control, string msg)
{
Control. Page.ClientScript.RegisterClientScriptBlock (Control. Page.gettype (), "B", "Alert ('" + MSG.) ToString () + "');", true);
}
///<summary>
///Control Click the Message confirmation prompt box
///</summary>
///<param name= "page" > current page pointer, generally this</param>
///<param name= "MSG" > Hint info </param>
public static void Showconfirm (System.Web.UI.WebControls.WebControl control, string msg)
{
CONTROL.ATTRIBUTES.ADD ("OnClick", "If" (!window.confirm (' "+msg+")) {return false;} ");
Control.Attributes.Add ("onclick", "return confirm (' + msg + ');");
}
///<summary>
///Displays the message prompt dialog box and makes a page jump
///</summary>
///<param name= "page" > current page pointer, generally this</param>
///<param name= "MSG" > Hint info </param>
///<param name= "url" > Jump target url</param>
public static void Showandredirect (System.Web.UI.Page Page, String msg, string URL, string frame)
{
StringBuilder Builder = new StringBuilder ();
builder.append ("<script language= ' JavaScript ' defer>");
Builder.appendformat ("alert (' {0} ');", msg);
Builder.appendformat ("top." + Frame + ". Location.href= ' {0} '", URL);
builder.append ("</script>");
Page. Clientscript.registerstartupscript (page. GetType (), "message", builder.tostring ());
}
///<summary>
///Output Custom script information
///</summary>
///<param name= "page" > current page pointer, generally this</param>
///<param name= "script" > Output script </param>
public static void Responsescript (System.Web.UI.Page Page, string script)
{
Page. Clientscript.registerstartupscript (page. GetType (), "message", "<script language= ' JavaScript ' defer>" + script + "</script>");
}
///<summary>
///Displays the message prompt dialog box and makes a page jump
///<param name= "page" > current page pointer, generally this</param>
///<param name= "MSG" > Hint info </param>
///<param name= "url" > Jump target url</param>
public static void Showandredirect (System.Web.UI.Page Page, String msg, string URL)
{
StringBuilder Builder = new StringBuilder ();
builder.append ("<script language= ' JavaScript ' defer>");
Builder.appendformat ("alert (' {0} ');", msg);
Builder.appendformat ("top.location.href= ' {0} '", URL);
builder.append ("</script>");
page. Clientscript.registerstartupscript (page. GetType (), "message", builder.tostring ());
}
}
}