button | data | refresh | page in some. NET Forum Some people often ask: How to click the button in the page to open a new page, enter data, and then return to the original page and update? To solve this problem, we should make clear the use of window.showModalDialog (), I have been introduced in http://www.csdn.net/Develop/read_article.asp?id=15113. Here is an example of how to implement this functionality in ASP.net.
This example is a total of 3 pages, where webform2.aspx is a transition page to prevent the new page from being opened when it is submitted.
WebForm1.aspx
<%@ Page language= "vb" autoeventwireup= "false" codebehind= "WebForm1.aspx.vb"
inherits= "Showmodaldialog.webform1"%>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta content= "Microsoft Visual Studio. NET 7.0" name= "Generator" >
<meta content= "Visual Basic 7.0" name= "Code_language" >
<meta content= "JavaScript" name= "vs_defaultClientScript" >
<meta content= "http://schemas.microsoft.com/intellisense/ie5" name= "Vs_targetschema" >
</HEAD>
<body ms_positioning= "GridLayout" >
<div align= "center" >
<form id= "Form1" method= "POST" runat= "Server" >
<asp:label id= "Label1" runat= "Server" font-bold= "true" >
The example of opening a new window from the current page and passing the variable to the new window allows you to open the submission multiple times.
</asp:label><br>
<br>
<asp:textbox id= "TextBox1" runat= "Server" width= "600px" > This is the initial value and will be passed to the new window. </asp:textbox><br>
<br>
<asp:button id= "Button1" runat= "Server" text= "open Window" width= "96px" ></asp:button></form>
</div>
</body>
</HTML>
WebForm1.aspx.vb
Public Class WebForm1
Inherits System.Web.UI.Page
Protected WithEvents TextBox1 as System.Web.UI.WebControls.TextBox
Protected WithEvents Form1 as System.Web.UI.HtmlControls.HtmlForm
Protected WithEvents Label1 as System.Web.UI.WebControls.Label
Protected WithEvents Button1 as System.Web.UI.WebControls.Button
#Region the code generated by the Web Forms Designer
' This call is required by the Web Forms Designer.
<system.diagnostics.debuggerstepthrough () > Private Sub InitializeComponent ()
End Sub
Private Sub Page_Init (ByVal sender as System.Object, ByVal e as System.EventArgs) Handles Mybase.init
' CodeGen: This method call is required by the Web Forms Designer
' Do not modify it using the Code Editor.
InitializeComponent ()
End Sub
#End Region
Private Sub Page_Load (ByVal sender as System.Object, ByVal e as System.EventArgs) Handles MyBase.Load
' The user code to place the initialization page here
If (Not isclientscriptblockregistered ("ClientScript")) Then
Dim strscript as String = "<script>" + vbCrLf
Strscript + = "function Openwin () {" + VbCrLf
Strscript + = "var Str=window.showmodaldialog" (' webform2.aspx ', document. Form1.TextBox1.value) "+ vbCrLf
Strscript + = "if (str!=null) document." Form1.textbox1.value=str "+ vbCrLf
Strscript + = "}" + VbCrLf
Strscript = "</script>" + vbCrLf
RegisterClientScriptBlock ("ClientScript", Strscript)
End If
BUTTON1.ATTRIBUTES.ADD ("onclick", "Openwin ()")
End Sub
End Class
Webform2.aspx
<%@ Page language= "vb" autoeventwireup= "false" codebehind= "WebForm2.aspx.vb" inherits= " AspxWeb.mengxianhui.com.WebForm2 "%>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<HTML>
<HEAD>
<title>WebForm2</title>
<meta name= "generator" content= "Microsoft Visual Studio. NET 7.0" >
<meta name= "Code_language" content= "Visual Basic 7.0" >
<meta name= "vs_defaultClientScript" content= "JavaScript" >
<meta name= "vs_targetschema" content= "http://schemas.microsoft.com/intellisense/ie5" >
</HEAD>
<frameset rows= "0,*" >
<frame src= "About:blank" >
<frame src= "Webform3.aspx" >
</frameset>
</HTML>
WebForm2.aspx.vb
Public Class WebForm2
Inherits System.Web.UI.Page
#Region the code generated by the Web Forms Designer
' This call is required by the Web Forms Designer.
<system.diagnostics.debuggerstepthrough () > Private Sub InitializeComponent ()