showModalDialog多值传输问题,高分求助
ywcyj 2003-07-08 08:12:51 在goody9807的帮助下,已经实现用showModalDialog传输单值。
现在想知道多值如何传输和返回,是不是要用数组
例如需要将WebForm2中TextBox1和TextBox2的值传给user.aspx,最后返回两个值分别赋给TextBox1和TextBox2。下面的程序应该如何修改
WebForm2.aspx.vb
Inherits System.Web.UI.Page
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
Protected WithEvents Button2 As System.Web.UI.WebControls.Button
Protected WithEvents TextBox2 As System.Web.UI.WebControls.TextBox
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Button1.Attributes.Add("onclick", "var st=window.showModalDialog('user.aspx?val='+document.all('TextBox1').value);document.all('TextBox1').value=st;return st;")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
RegisterStartupScript("key", "<script>window.opener=null;window.close(this);</script>")
End Sub
user.aspx.vb
Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
Protected WithEvents cancel As System.Web.UI.WebControls.Button
Protected WithEvents ok As System.Web.UI.WebControls.Button
Protected WithEvents TextBox2 As System.Web.UI.WebControls.TextBox
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim str As String
If Not IsPostBack Then
str = Request.QueryString("val")
TextBox1.Text = str
End If
End Sub
Private Sub cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cancel.Click
RegisterStartupScript("key", "<script>window.returnValue='null';window.opener=null;window.close(this);</script>")
End Sub
Private Sub ok_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ok.Click
RegisterStartupScript("key", "<script>window.returnValue=document.all('TextBox2').value;window.opener=null;window.close(this);</script>")
End Sub