to mynewpc(水中日月)你是用的url传值,user.aspx?val=v1&val1=v2&val2=v3,这样不就行了.用url传出多值我知道 只是不清楚如何返回多值?to net_lover(孟子E章) 传数组对象我考虑过,但由于不懂javasript,不会将java里的数组赋给服务器端的某个变量或者对象
传一个字符串用特殊的字符*进行分隔webform2.aspx Button1.Attributes.Add("onclick", "var st=window.showModalDialog('user.aspx?val='+document.all('TextBox1').value+'*'+document.all('TextBox2').value);document.all('TextBox1').value=st;return st;")user.aspx Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here Dim str As String Dim i As Integer Dim l As String Dim r As String Dim len1 As Integer str = Request.QueryString("val") len1 = Len(str) i = str.IndexOf("*") l = str.Substring(0, i) r = str.Substring(i + 1, len1 - i - 1) TextBox1.Text = l TextBox2.Text = r 'Response.Write(l) End Sub我测试通过!没问题!
to goody9807() 你的代码没问题,谢谢 但只返回了一个值 现在需要user.aspx返回两个值,分别赋给webform2.aspx的TextBox1和TextBox2 我就是搞不定这个问题 呵呵
to goody9807() 1、很怪,现在返回的值是webform2.aspx传过去的TextBox1和TextBox2的值,而不是user.aspx中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 Dim i As Integer Dim l As String Dim r As String Dim len1 As Integer str = Request.QueryString("val") len1 = Len(str) i = str.IndexOf("*") l = str.Substring(0, i) r = str.Substring(i + 1, len1 - i - 1) TextBox1.Text = l TextBox2.Text = r 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('TextBox1').value+'*'+document.all('TextBox2').value;window.opener=null;window.close(this);</script>") End Sub
我没给你写完 user.aspx 需要再添加一个Textbox4 用来存接到的直(2个 中间加*) Private Sub ok_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ok.Click RegisterStartupScript("key", "<script>window.returnValue=document.all('TextBox4').value;window.opener=null;window.close(this);</script>") ~~~ End Sub
只是不清楚如何返回多值?to net_lover(孟子E章)
传数组对象我考虑过,但由于不懂javasript,不会将java里的数组赋给服务器端的某个变量或者对象
Button1.Attributes.Add("onclick", "var st=window.showModalDialog('user.aspx?val='+document.all('TextBox1').value+'*'+document.all('TextBox2').value);document.all('TextBox1').value=st;return st;")user.aspx
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim str As String
Dim i As Integer
Dim l As String
Dim r As String
Dim len1 As Integer
str = Request.QueryString("val")
len1 = Len(str)
i = str.IndexOf("*")
l = str.Substring(0, i)
r = str.Substring(i + 1, len1 - i - 1)
TextBox1.Text = l
TextBox2.Text = r
'Response.Write(l)
End Sub我测试通过!没问题!
但只返回了一个值
现在需要user.aspx返回两个值,分别赋给webform2.aspx的TextBox1和TextBox2
我就是搞不定这个问题
呵呵
你简直太聪明了用你的办法那还不是返回一个参数,这就带来一个问题
返回的值在webform2.aspx上自动更新TextBox1和TextBox2的显示有点麻烦,
所以最好直接返回2个值
http://www.csdn.net/Develop/read_article.asp?id=15113
1、很怪,现在返回的值是webform2.aspx传过去的TextBox1和TextBox2的值,而不是user.aspx中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
Dim i As Integer
Dim l As String
Dim r As String
Dim len1 As Integer
str = Request.QueryString("val")
len1 = Len(str)
i = str.IndexOf("*")
l = str.Substring(0, i)
r = str.Substring(i + 1, len1 - i - 1)
TextBox1.Text = l
TextBox2.Text = r
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('TextBox1').value+'*'+document.all('TextBox2').value;window.opener=null;window.close(this);</script>")
End Sub
Button1.Attributes.Add("onclick", "var st=window.showModalDialog('user.aspx?val='+document.all('TextBox1').value);document.all('TextBox3').value=st;return st;") ~然后从这个添加的Textbox取出返回直 并分成2个 分别赋值 Textbox1 \ textbox2
从添加的Textbox取出返回直 并分成2个 分别赋值 Textbox1 \ textbox2
这个我明白现在返回的值好像不对
初始:WebForm2.aspx中TextBox1为"1",TextBox2为"2"
提交传递值给user.aspx,user.aspx中TextBox1显示为"1",TextBox2显示为"2"
user.aspx:修改TextBox1为"3",TextBox2为"4"
提交应该返回"3*4"给WebForm2.aspx中的TextBox3,但返回值却是"1*2"我没看出来是哪儿写的不对
这个我明白现在返回的值好像不对
初始:WebForm2.aspx中TextBox1为"1",TextBox2为"2"
提交传递值给user.aspx,user.aspx中TextBox1显示为"1",TextBox2显示为"2"
user.aspx:修改TextBox1为"3",TextBox2为"4"
提交应该返回"3*4"给WebForm2.aspx中的TextBox3,但返回值却是"1*2"
user.aspx
需要再添加一个Textbox4 用来存接到的直(2个 中间加*) Private Sub ok_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ok.Click
RegisterStartupScript("key", "<script>window.returnValue=document.all('TextBox4').value;window.opener=null;window.close(this);</script>")
~~~
End Sub
可能是两个TextBox1名字相同的缘故
谢谢
结贴