父页面代码:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'在此处放置初始化页的用户代码
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
Session("AA") = TextBox1.Text
Button1.Attributes.Add("onclick", "OpenWin()")
End Sub子页面代码:
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问题出来了,在子页面上textBox1显示是有值的,也就是说父页面的值已经传过来了,但我怎么也取不到这个值,这个值该怎么取?比如我要在LOAD里面写一个SQL语句,如"select * from zTAB where id='& textbox1.text &'"
textbox1.text的值总是为空,怎么才能取到textbox1的值啊?
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'在此处放置初始化页的用户代码
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
Session("AA") = TextBox1.Text
Button1.Attributes.Add("onclick", "OpenWin()")
End Sub子页面代码:
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问题出来了,在子页面上textBox1显示是有值的,也就是说父页面的值已经传过来了,但我怎么也取不到这个值,这个值该怎么取?比如我要在LOAD里面写一个SQL语句,如"select * from zTAB where id='& textbox1.text &'"
textbox1.text的值总是为空,怎么才能取到textbox1的值啊?
解决方案 »
- VS2010 中为什么找不到 Framework3.5 2.0?
- 求教:如何删除CKeditor的部分功能
- 瞧一瞧看一看给我的建议来者给分!!
- vs2005 C#数据库字符串问题,在线等待.
- 高人,请指教,能回答这样的问题能拿多少薪水?
- asp.net 如何实现发送和接收即时消息
- treeview控件使用的问题,图片怎么点几下就不在了.
- 求救高手:我把.NET Framework1.0删除掉以后,重装.NET Framework1.1 之后,VS.NET 不能用了??
- 怎样确定是否是周末?
- asp.net点击下载,下载的是当前页面
- 在利用.NET作网络程序过程中,遇到的两个问题 急!!!!!!!
- 闲着也闲着,再送点分
加空格试试
子窗体的这段代码是加载TextBox1的值的
MyBody.Attributes.Add("onload", "document.Form1.TextBox1.value=window.parent.dialogArguments")
在页面上是显示传过来的值了,但代码里不知道怎么取.
MyBody.Attributes.Add("onload", "document.Form1.TextBox1.value=window.parent.dialogArguments")
End If怎么在LOAD里取到textBox1的值啊?
直接取TextBox1的值为空,是不是要用脚本语言取值?
document.getElementById("TextBox1").innerText
Dim aa As String = document.getElementById("TextBox1").innerText()
这样取报错
var aa=document.getElementById("TextBox1").innerText
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
MyBody.Attributes.Add("onload", "document.Form1.TextBox1.value=window.parent.dialogArguments")#######################
dim aa as string=document.getElementById("TextBox1").innerText
dim sql as string="select * from zTAB where id='"& aa &"'"
######################
End If
End Sub我想达到上面的效果,不知道怎么写.在Page_Load里面
dim aa as string=TextBox1.Text
这样试试
父窗体代码已经有了,在子窗体Page_Load中我想获取父窗体提交过来的值,得到一个SQL语句,如下代码
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
MyBody.Attributes.Add("onload", "document.Form1.TextBox1.value=window.parent.dialogArguments")
dim sql as string="select * from zTAB where id='"& TextBox1.text &"'"
End Sub
但textbox1.text的值是为空的,怎么取到父窗体提交过来的值呢?
#######################
dim aa as string=document.getElementById("TextBox1").innerText
dim sql as string="select * from zTAB where id='"& aa &"'"
######################
这些,你先试试MyBody.Attributes.Add("onload", "document.getElementById("TextBox1").innerText=window.parent.dialogArguments")
看能不能把值写到TextBox1中去。能不能在页面上把值显示出来。
父窗体:
strScript="<script language=javascript>document.getElementById("TextBox1").innerText=window.showModalDialog('../Workflow/DownUser.aspx?UserID='+escape("+base.Visitor.uploaddown+")+'&WorkFlow=Upload','','center:yes;dialogWidth:400px;dialogHeight:150px;help:no;status:no');objButton=document.getElementById('btn_downflow');focus(objButton);objButton.click();</script>";
父窗体打开一个模式窗体DownUser.aspx,传一个变量UserID给子窗体,在父窗体中有一个TextBox1控件用来得到子窗体的返回值。
在子窗体中用Request["UserID"].ToString()得到父窗体传过来的值
我用我的代码解释了一下,看是不是你要问的
http://dotnet.aspx.cc/ShowDetail.aspx?id=49ML4AO8-5PB3-4KNY-NJZD-LJOIOXV4M1X4
这篇文章的方法是如何点击按钮弹出新窗口,输入数据后返回并刷新页面.但没有写子页面在Page_Load里得到父页面的值
真不好意思,麻烦你这么久...