webform3.aspx.vb
public Class WebForm3
Inherits System.Web.UI.Page
Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected MyBody As System.Web.UI.HtmlControls.HtmlControl
#region " Web 窗体设计器生成的代码 "
''该调用是 Web 窗体设计器所必需的。
<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: 此方法调用是 Web 窗体设计器所必需的
''不要使用代码编辑器修改它。
InitializeComponent()
End Sub
#end Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
''在此处放置初始化页的用户代码
If IsPostBack Then
Dim strScript As String = "<script>" + vbCrLf
strScript += "window.parent.returnValue=''" + TextBox1.Text.Replace("''", "\''") + "''" + vbCrLf
strScript += "window.parent.close()" + vbCrLf
strScript += "</script>" + vbCrLf
If (Not IsClientScriptBlockRegistered("clientScript")) Then
RegisterClientScriptBlock("clientScript", strScript)
End If
End If
If Not IsPostBack Then
MyBody.Attributes.Add("onload", "document.Form1.TextBox1.value=window.parent.dialogArguments")
End If
End Sub
End Class