CS后台程序中如何让右框架页面在调用过程方法时赋值给顶部框架页的label控件
通过百度搜索都没有得到解决
网页整个分为顶部,左边框,右边框
现在需要在右边框执行某个按钮事件的后台程序中,刷新顶部页面的一个label统计值
采用
this.Response.Write("<script>window.frames[\"top\"].document.all(\"error\").Text='100';</script>");
和
Page.ClientScript.RegisterStartupScript(GetType(), "mykey",
"<script>window.parent.frames(\"top\").document.error.value ='99';</script>");
this.Response.Write("<script>window.parent.frames[\"top\"].document.all(\"error\").value='" + datatable.Rows.Count.ToString() + "';</script>");
方法都不能成功给顶部的label成功赋值
以上的error就是lable控件的ID值
注意不是在aspx页面调用
网页整个分为顶部,左边框,右边框
现在需要在右边框执行某个按钮事件的后台程序中,刷新顶部页面的一个label统计值
采用
this.Response.Write("<script>window.frames[\"top\"].document.all(\"error\").Text='100';</script>");
和
Page.ClientScript.RegisterStartupScript(GetType(), "mykey",
"<script>window.parent.frames(\"top\").document.error.value ='99';</script>");
this.Response.Write("<script>window.parent.frames[\"top\"].document.all(\"error\").value='" + datatable.Rows.Count.ToString() + "';</script>");
方法都不能成功给顶部的label成功赋值
以上的error就是lable控件的ID值
注意不是在aspx页面调用
...全文
请发表友善的回复…
发表回复
以专业开发人员为伍 2014-11-10
- 打赏
- 举报
http://www.w3school.com.cn/jsref/dom_obj_window.asp
你可以在你动态输出的 javascript 的最前边,插入一个
debugger;
或者break;
语句,这样vs(当你使用ie做为默认浏览器的时候)就会跳入调试模式,你可以手动查看你的代码要访问的各层对象的属性值。chenchen_2011 2014-11-10
- 打赏
- 举报
问题应该聚焦在JS的代码上
右边框页面访问顶部框架页的控件对象出错
在右边框页中写JS函数ALERT(顶部框架页的控件)都没有任何反应,直接弹出常量是没有问题的
请教--右边框页面访问顶部框架页的控件对象的JS代码如何写
本人对JS不怎么熟悉
wszhoho 2014-11-10
- 打赏
- 举报
那就改成你自己的window.parent.frames["top"].document.getElementById("error").innerHTML
chenchen_2011 2014-11-10
- 打赏
- 举报
span是用innerHTML赋值的
top.document.getElementById("error").innerHTML="adfasfasfas";[/quote]
使用这样的代码执行还是不对呢
this.Response.Write("<script>top.document.getElementById(\"error\").innerHTML=\"" + dt_Step.Rows.Count.ToString() + "\";</script>");
还是左下角报错:
消息: 'top.document.getElementById(...)' 为空或不是对象
执行后的网页源代码中显示的是:
<script>top.document.getElementById("error").innerHTML="3";</script>
wszhoho 2014-11-10
- 打赏
- 举报
span是用innerHTML赋值的
top.document.getElementById("error").innerHTML="adfasfasfas";
chenchen_2011 2014-11-10
- 打赏
- 举报
查看执行后的网页源代码:
<script>window.parent.frames["top"].document.all("error").value='100';</script>
value和text都已经试过,不管怎么赋值都顶部页面的控件值都没有变化
zhrongr 2014-11-10
- 打赏
- 举报
this.Response.Write("<script>window.frames[\"top\"].document.all(\"error\").Text='100';</script>");把Text改成Value试试
wszhoho 2014-11-10
- 打赏
- 举报
span是用innerHTML赋值的
chenchen_2011 2014-11-10
- 打赏
- 举报
查看执行后的网页源代码,控件的ID确实还是<span id="error" style="color:Red;font-weight:bold;"> (3)条</span>
wszhoho 2014-11-10
- 打赏
- 举报
确定error控件的ClientID就是“error”?
insus 2014-11-10
- 打赏
- 举报
这个问题,如果在masterpage内,是较容易实现。