将值从Javascript传递到ASP.net控件 [英] Passing value from Javascript to ASP.net control

查看:64
本文介绍了将值从Javascript传递到ASP.net控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个

Hi,

I have a Javascript that I called using the the

ScriptManager.RegisterClientScriptBlock

调用的Javascript.该脚本将生成一个弹出窗口,我可以在其中浏览文件的路径.当我单击确定"按钮时,它将调用JS函数:

. The script will generate a Pop-up window where i can browse for the path of the file. When I click the OK button it will call a JS function:

function SelectAndClose() {
            txtValue = document.getElementById('_browseTextBox');

            window.returnValue = txtValue.value;
            window.close();
            return false;
        }



我对如何将txtValue变量传递到上一页并使用该值显示在文本框中感到非常困惑.非常感谢您的帮助.

谢谢!

Franco



I am quite confused on how I can pass the txtValue variable to the previous page and use the value to display in a textbox..any help is greatly appreciated.

Thanks!

Franco

推荐答案

以这种方式重写函数
Rewrite your function this way
function SelectAndClose() {
            txtValue = document.getElementById('_browseTextBox');
        if ((window.opener != null) && (window.opener && !window.opener.closed)) {
               window.opener.InvokeParent(txtValue.value);
        }
            window.close();
            return false;
        }


现在在父页面.aspx的脚本块中编写以下函数


Now Write Following Function in script block of .aspx of Parent Page

<script type="text/javascript">
    function InvokeParent(varValue){
      if(varValue != ""){
        // Write Required Statements to perform whatever operation
       }
    }
</script>


这篇关于将值从Javascript传递到ASP.net控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆