在javascript中将值从子级传递到父级 [英] passing value from child from to parrent in javascript
问题描述
我有一个父母形式和一个孩子形式.
我正在将选定的id的值从radgrid传递到子页面.并通过查询字符串接收该值
像这样.........
i have one parent form and a child form.
i am passing the value of selected id from radgrid to child page.and receive the value through query string
like this..................
var text;
function RowSelected(sender, args) {
document.getElementById("<%=Label4.ClientID %>").innerHTML = args.getDataKeyValue("Number");
text = document.getElementById("<%=Label4.ClientID %>").innerHTML;
}
function ClosedClicked() {
window.open("PurchaseOrderpopuptest.aspx?controlID=" + text);
}
在我的子页面中获得这样的价值
..............................................
in my child page receiving value like this
.....................................
string controlID = "";
protected void Page_Load(object sender, EventArgs e)
{
controlID = Request["controlID"].ToString ();
TextBox1.Text = controlID;
}
....................................
那么我要做的就是将值发送回家长页面
...........................
then what i want to do is i want send the value back to parrent page
function sendvalue() {
var textval = document.getElementById('TextBox1').value;
alert(textval);
window.opener.document.forms.namedItem('Label6') = textval;
window.close();
return false;
}
如果我对此行发表评论
if i comment this line
window.opener.document.forms.namedItem('Label6') = textval;
然后执行脚本但使用htis行脚本未执行
因此,任何人都可以帮助我解决该问题.
label6是父页面的控件
谢谢
then the script execute but with htis line script is not executing
so, anyone help me how to solve this problem.
label6 is the control of parent page
Thank You
推荐答案
如果有帮助,请参阅以下文章:
^ ]
See below article if it helps you:
http://weblogs.asp.net/ssnair/archive/2010/05/16/how-to-pass-value-from-child-window-to-parent-window-without-refreshing-the-page-using-masterpage.aspx[^]
确保Label6不是服务器控件. clientID可能不是Label6.
例如,如果标签位于面板上,则clientid将为Panel1_Label6
Make sure Label6 is not a server control. The clientID may be not Label6.
For example if the label sits on a panel clientid will be Panel1_Label6
这篇关于在javascript中将值从子级传递到父级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!