ASP.NET 和Javascript:将值从一个窗口设置到另一个窗口
我有一个从父应用程序打开的子浏览器窗口(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:不支持这样的接口”。
有人有什么想法吗?
谢谢,
杰森
I have a child browser window (aspx) opened from the parent application. The child window has some controls, and a textbox. When the user is finished, s/he clicks a button and the following code takes the value from the child window and populates the parent, like so:
window.opener.document.form1.InputContainer$LetterInput$txtReasons.value = txtVal;
This works great for the textbox I have on the parent page. But now, I need to populate a listbox and am not having much luck. I've tried these two methods but to no avail:
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");
I get "htmlfile: No such interface supported" with both.
Anybody have any ideas?
Thanks,
Jason
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,做了一些修改,但找到了解决方案!
首先,在父 aspx 中创建一个函数,如下所示:
然后,从子页面调用该函数,如下所示:
仍然存在一两个问题(它只传递文本,而不传递值),但可以通过以下方式轻松修复:添加额外的参数...
希望其他人可以使用它!
Okay, took a little reworking but found a solution!
First off, create a function in the parent aspx like this:
Then, call that function from the child page like this:
There's still a kink or two (it only passes the text, not the value) but it that can be easily fixed by adding an extra parameter...
Hopefully someone else out there can use it!