0
<script type="text/javascript" language="javascript">
function PostData() {

         var NameID = '<%= this.Request.QueryString["UN"] %>';

         window.showModalDialog('PopUp.aspx?UN=' + cosh +'',  'height=400,width=450');
         window.opener.document.getElementById(NameID).innerHTML = document.getElementById('<%= cosh.ClientID%>').value;
         return false;
     }
 </script>

<script type="text/javascript" language="javascript" >
    var cosh = '<%= gelen_cosh.ClientID %>';

</script>

我使用这种方法来保持正在发送的数据。
观察一种发送数据的方式,如上所示,但“cosh”表示未定义的变量。我走对了吗?你能提供一个例子或文件吗?

4

1 回答 1

0

尝试交换脚本块的位置,以便

<script type="text/javascript" language="javascript" >
    var cosh = '<%= gelen_cosh.ClientID %>';

</script>

首先出现,否则它会认为不是未定义的

或者只是将它们放在同一个脚本块中

<script type="text/javascript" language="javascript">
function PostData() {

         var cosh = '<%= gelen_cosh.ClientID %>';
         var NameID = '<%= this.Request.QueryString["UN"] %>';

         window.showModalDialog('PopUp.aspx?UN=' + cosh +'',  'height=400,width=450');
         window.opener.document.getElementById(NameID).innerHTML = document.getElementById('<%= cosh.ClientID%>').value;
         return false;
     }
 </script>

公平地说,一旦你完成了他们可能是其他错误。看看进展如何

干杯

编辑

尝试这个。您在 cosh 变量上获得了一个客户端 ID,该变量本身只是一个字符串形式的客户端 ID。您需要立即执行 document.getElementById

<script type="text/javascript" language="javascript">
function PostData() {

         var NameID = '<%= this.Request.QueryString["UN"] %>';
         var cosh = document.getElementById('<%= gelen_cosh.ClientID%>');

         window.showModalDialog('PopUp.aspx?UN=' + cosh +'',  'height=400,width=450');
         window.opener.document.getElementById(NameID).innerHTML = cosh.value;
         return false;
     }
 </script>
于 2013-06-27T14:35:01.047 回答