这是子窗口print.aspx 的js
<script type='text/javascript'>
var jydbh=window.dialogArguments.document.getElementById('txtjydbh');
var ysfs = window.dialogArguments.document.getElementById('ddlysfs');
document.getElementById('lbljydbh')=jydbh.value;
//将从父窗口获取到的值赋予lbljydbh控件 怎么就不行呢?
</script>
<script type='text/javascript'>
var jydbh=window.dialogArguments.document.getElementById('txtjydbh');
var ysfs = window.dialogArguments.document.getElementById('ddlysfs');
document.getElementById('lbljydbh')=jydbh.value;
//将从父窗口获取到的值赋予lbljydbh控件 怎么就不行呢?
</script>
解决方案 »
- C# 获取cookies问题
- windows7 64位系统下不能安装Visual Studio 2008 文档
- 在c#里调用native dll除了使用dllimport attribute,还有别的方法么?
- 用什么方法移除Dictionary的第一项和最后一项
- 我是按照书的例子写的代码,讲的是递归的例子有误!!
- 超级傻的问题,请进来相助。。
- 我想问个问题...关于C#和SQL的DateTimePicker!
- winform 内存释放、垃圾回收
- RDLC 如何做单页合计
- Insert 出错,不知道是原因!!急,在线!!!!
- MemoryStream stream = new MemoryStream(b, true);
- BindingSource 记录集如何设成唯读,用户不能修改
给个建议啊
不行啊 这么做的话 提示
Microsoft JScript 运行时错误: 'document.getElementById(...)' 为空或不是对象
{
var jydbh = document.getElementById("txtjydbh").value;
//var zdtime = document.getElementById("txtjhrq").value;
var ysfs = document.getElementById("ddlysfs").value;
revalue = window.showModalDialog('print.aspx',window,'dialogHeight:530px;dialogWidth:698px;dialogTop:screen.height/2;dialogLeft:screen.width/2; edge:sunken ; center: Yes; help: No; resizable: No; status: No; scroll:yes;');
} <asp:Button ID="btnPrint" runat="server" Text="打印预览" AccessKey="p" OnClientClick="openpri();" />子窗口print.aspx 代码
<script type='text/javascript'>
var jydbh=window.dialogArguments.document.getElementById('txtjydbh');
var ysfs = window.dialogArguments.document.getElementById('ddlysfs');
alert(jydbh.value);
alert(ysfs.value);//这边都有值
document.getElementById('lbljydbh').value=jydbh.value;//到这步就是获取不到值</script>
<div style="position:absolute; left: 382px; top: 62px; width: 147px;"><asp:Label ID="lbljydbh" runat="server" ></asp:Label></div>
---a.js--A.html调用的js
var arrParam = [];// 首次创建个数组
arrParam[0] ="张三";//姓名
arrParam[1] ="18";//年龄
var retuPar=window.showModalDialog(B.html',arrParam); //打开窗口并且传值--arrParam--B.html会接到数组
---b.js--B.html调用
var arrParam = window.dialogArguments;// dialogArguments就是 父页面传递过来的参数集合 ---B.html 调用
document.getElementById("nametxt").value = arrParam[0];
document.getElementById("agetxt").value = arrParam[1];
这样就将结果传递过来并且使用了 然后你还可以关闭 这个子页面将结果反回去 可以是任意类型 也可以是数组
例如:
var arrdata=new Array();
arrdata[0]="ok";
window.returnValue=arrdata;
window.close(); //关闭打开的窗口
这样就将arrdata这个数组返回给 父亲窗体的 retuPar 了 。
第一个文件 A.html<html xmlns="http://www.w3.org/1999/xhtml">
<META http-equiv=Content-Type content=text/html;charset=gb2312>
<head>
<script src="a.js"></script>
</head>
<body>
<form>
姓名:<input type='txt' value='' id='name'><br>
年龄:<input type='txt' value='' id='age'><br>
<input type = 'button' onclick='showmod()' value='传递到子窗体'>
</form>
</body>
</html>第二个文件<html xmlns="http://www.w3.org/1999/xhtml">
<META http-equiv=Content-Type content=text/html;charset=gb2312>
<head>
<script src="b.js"></script>
</head>
<body>
<form>
接收到姓名:<input type='txt' value='' id='name'><br>
接收到年龄:<input type='txt' value='' id='age'><br>
输入返回值:<input type='txt' value='' id='jg'><br>
<input type = 'button' onclick='retClose()' value='关闭返回'>
</form>
</body>
</html>第三个文件function showmod()
{
var arrayList = [];
arrayList[0] = document.getElementById("name").value;
arrayList[1] = document.getElementById("age").value;
var revalue = window.showModalDialog('B.html',arrayList,'dialogHeight:530px;dialogWidth:698px;dialogTop:screen.height/2;dialogLeft:screen.width/2; edge:sunken ; center: Yes; help: No; resizable: No; status: No; scroll:yes;');
alert("返回结果为:"+revalue[0]);
}第四个文件window.onload = loadPar; //初始化加载
//接收主窗体传递过来的参数
function loadPar()
{
var arrParam = window.dialogArguments;
document.getElementById("name").value = arrParam[0];
document.getElementById("age").value = arrParam[1];
}
//返回
function retClose()
{
var arrdata=new Array();
arrdata[0]=document.getElementById("jg").value;
window.returnValue=arrdata;
window.close();
}
a.html
第二个文件叫
b.html
第三个文件叫
a.js
第四个文件叫
b.js
不让我编辑。。
var arrayList = [];
arrayList[0] = document.getElementById("txtjydbh").value;
arrayList[1] = document.getElementById("ddlysfs").value;
var revalue = window.showModalDialog('print.aspx',arrayList,'dialogHeight:530px;dialogWidth:698px;dialogTop:screen.height/2;dialogLeft:screen.width/2; edge:sunken ; center: Yes; help: No; resizable: No; status: No; scroll:yes;');
}b.html改为了print.aspx 代码如下
function getValue()
{
var arrParam = window.dialogArguments;
document.getElementById("lbljydbh").value = arrParam[0];
document.getElementById("lblysfs").value = arrParam[1];
}window.onload = loadPar; //初始化加载 ,这个要写在哪里呢?
page_load()中? 怎么写????
帮我改成aspx页面的吧
Microsoft JScript 运行时错误: 错误的参数个数或无效的参数属性值如果用document.getElementById("lbljydbh").value= arrParam[0]; 提示以下错误:
'document.getElementById("lbljydbh")' 为空或者不是对象
jiangsong2004
是的 我只要把父窗口的值(父窗口有许多的label 需要传值) 传到子窗口 不用返回值
用的是vs2008
保存完后,就通过jydbh这个参数 马上获取这票的信息
我原来也是用的url传值的 但是 刚保存进去的 不能马上取出值(好像有缓存吧)var revalue = window.showModalDialog('print.aspx?jydbh='"+jydbh+"'','','dialogHeight:530px;dialogWidth:698px;dialogTop:screen.height/2;dialogLeft:screen.width/2; edge:sunken ; center: Yes; help: No; resizable: No; status: No; scroll:yes;');jydbh 已经可以传到子窗口 然后再根据这个参数 来获取所有的信息 string strsql = "select jydbh,jhrq,ysfs,sxhh,sdz,zdz,thfs from jydxx where jydbh='"+jydbh+"' ";
SqlCommand cmd = new SqlCommand(strsql, conn);
SqlDataReader rdr = cmd.ExecuteReader();
jiangsong2004
jiangsong2004