父页面代码:
    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的值啊?

解决方案 »

  1.   

    select * from zTAB where id='"& textbox1.text &"'
      

  2.   

    select * from zTAB where id=' " & textbox1.text & " '
    加空格试试
      

  3.   

    不是SQL语句的问题,是textBox1.text在后台代码里值就是为空的.
      

  4.   

    事实上textBox1在页面上显示有父页面传过来的值,但代码里textBox1.text是为空,这是为什么,怎么才能取到textBox1.text的值呢?
      

  5.   

    你用html控件中的text field控件试试,把这个控件设置为服务器控件,设置他的id为TextBox1,在脚本中:document.Form1.TextBox1.value服务器端为:TextBox1.value
      

  6.   

    不是控件的问题吧
    子窗体的这段代码是加载TextBox1的值的
    MyBody.Attributes.Add("onload", "document.Form1.TextBox1.value=window.parent.dialogArguments")
    在页面上是显示传过来的值了,但代码里不知道怎么取.
      

  7.   

    If Not IsPostBack Then
                MyBody.Attributes.Add("onload", "document.Form1.TextBox1.value=window.parent.dialogArguments")
    End If怎么在LOAD里取到textBox1的值啊?
    直接取TextBox1的值为空,是不是要用脚本语言取值?
      

  8.   

    求教了,大侠们帮帮我,用脚本语言怎么取textBox1的值?
      

  9.   

    在脚本中取textbox的值
    document.getElementById("TextBox1").innerText
      

  10.   

    你的TextBox1是什么控件,如果是textbox那么就是上面的代码
      

  11.   

    textbox1是Web组件,怎么取值能详细点吗?
    Dim aa As String = document.getElementById("TextBox1").innerText()
    这样取报错
      

  12.   

    你不是说在脚本中吗?
    var aa=document.getElementById("TextBox1").innerText
      

  13.   

    我说是不是在脚本中,是在load代码里
    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里面
      

  14.   

    你把值放在Hidden控件里再取试试
      

  15.   

    MyBody.Attributes.Add("onload", "document.getElementById("TextBox1").innerText=window.parent.dialogArguments")
    dim aa as string=TextBox1.Text
    这样试试
      

  16.   

    可能我的表达不是很好
    父窗体代码已经有了,在子窗体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的值是为空的,怎么取到父窗体提交过来的值呢?
      

  17.   

    你先不要加
    #######################
    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中去。能不能在页面上把值显示出来。
      

  18.   

    MyBody.Attributes.Add("onload", "document.getElementById("TextBox1").innerText=window.parent.dialogArguments")这一句语法通不过...  document.getElementById("TextBox1")括号这里
      

  19.   

    不知道我理解的对不对:
    父窗体:
    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()得到父窗体传过来的值
    我用我的代码解释了一下,看是不是你要问的
      

  20.   

    差不多啦,我是看到这篇文章按上面方法做的
    http://dotnet.aspx.cc/ShowDetail.aspx?id=49ML4AO8-5PB3-4KNY-NJZD-LJOIOXV4M1X4
    这篇文章的方法是如何点击按钮弹出新窗口,输入数据后返回并刷新页面.但没有写子页面在Page_Load里得到父页面的值
    真不好意思,麻烦你这么久...