将值从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>