ASP.NET及;Javascript:设置从一个窗口到另一个窗口的值

ASP.NET及;Javascript:设置从一个窗口到另一个窗口的值,javascript,asp.net,parent,window.opener,Javascript,Asp.net,Parent,Window.opener,我有一个从父应用程序打开的子浏览器窗口(aspx)。子窗口有一些控件和一个文本框。当用户完成时,他/她单击一个按钮,下面的代码从子窗口获取值并填充父窗口,如下所示: window.opener.document.form1.InputContainer$LetterInput$txtReasons.value = txtVal; 这对我在父页面上的文本框非常有用。但是现在,我需要填充一个列表框,而且运气不太好。我试过这两种方法,但都没有用: o.text = txtVal; o.value =

我有一个从父应用程序打开的子浏览器窗口(aspx)。子窗口有一些控件和一个文本框。当用户完成时,他/她单击一个按钮,下面的代码从子窗口获取值并填充父窗口,如下所示:

window.opener.document.form1.InputContainer$LetterInput$txtReasons.value = txtVal;
这对我在父页面上的文本框非常有用。但是现在,我需要填充一个列表框,而且运气不太好。我试过这两种方法,但都没有用:

o.text = txtVal;
o.value = "1";
window.opener.document.form1.InputContainer$LetterInput$lstReasons.add(o);

window.opener.document.form1.InputContainer$LetterInput$lstReasons.add("Text", "Value");
我得到了“htmlfile:不支持这样的接口”这两个选项

有人有什么想法吗

谢谢

Jason

var newOption=document.createElement('option');
newOption.value=textbox.value;//此选项将具有的值
newOption.innerHTML=textbox.value;//标记内部显示的文本
//最后,将新选项添加到列表框中
window.opener.document.form1.InputContainer$letInput$lstReasons.appendChild(newOption);

好的,做了一些修改,但找到了解决方案

首先,在父aspx中创建一个函数,如下所示:

function NewOption(newVal)
{
//alert("The entry is: " + newVal);
var sel = document.getElementById("<%= MyListbox.clientID %>");
sel.options[sel.options.length]=new Option(newVal, newVal, true, true);    
}
function SendValues()
{
var txtVal = document.form1.txtReasons.value;
var sel = window.opener.NewOption(txtVal);
}
仍然有一两个纠结(它只传递文本,而不是值),但可以通过添加一个额外的参数轻松修复


希望其他人可以使用它

在这一点上没有运气——仍然得到“不支持这样的接口”。但说真的,谢谢你的发帖!window.opener.document.getElementById('InputContainer\u LetterInput\u lstReasons')。appendChild。。。。。。。
function SendValues()
{
var txtVal = document.form1.txtReasons.value;
var sel = window.opener.NewOption(txtVal);
}