js怎么在弹出的子窗体中将DataGrid选中的某行值传回给父窗体
2007-06-21 21:46
274 查看
/* frmChild.aspx */
//弹出子窗口先绑定
this.datagrid1.DataBind();
//循环做事件
for(int i=0;i<this.datagrid1.Items.Count;i++)
{
str = this.datagrid1.Items[i].Cells[0].Text + "|" + this.datagrid1.Items[i].Cells[1].Text;
this.datagrid1.Items[i].Attributes.Add("onclick","foo('" + str + "');");
}
这样,点击每一行的时候,就会发生一个事件.再在脚本中写:
function foo(strRetValue)
{
window.returnValue = strRetValue;//传回给frmParent.aspx的字符串值
self.close();
}
如此,就把第1列及第2列值取回来了
如果让子窗口不开新窗口,加上base target="_self">即可.不支持IE5.0
/* frmParent.aspx */
function open()
{
var strRetValue=window.showModalDialog('frmChild.aspx?val=' + document.all('TextBox1').value + ',window,'dialogWidth:470px;dialogHeight:300px;scroll:no;center:yes;help:no;resizable:no;status:no');
document.all('TextBox1').value=strRetValue;//得到frmChild.aspx中传回来的值
//var strArr=strRetValue;//如果要将返回值转成数组
//var arr=strArr.split("|");
// alert(arr[0]); alert(arr[1]); ......
}
<a href="javasrcript:open();"> click to select data from datagrid1</a>
//弹出子窗口先绑定
this.datagrid1.DataBind();
//循环做事件
for(int i=0;i<this.datagrid1.Items.Count;i++)
{
str = this.datagrid1.Items[i].Cells[0].Text + "|" + this.datagrid1.Items[i].Cells[1].Text;
this.datagrid1.Items[i].Attributes.Add("onclick","foo('" + str + "');");
}
这样,点击每一行的时候,就会发生一个事件.再在脚本中写:
function foo(strRetValue)
{
window.returnValue = strRetValue;//传回给frmParent.aspx的字符串值
self.close();
}
如此,就把第1列及第2列值取回来了
如果让子窗口不开新窗口,加上base target="_self">即可.不支持IE5.0
/* frmParent.aspx */
function open()
{
var strRetValue=window.showModalDialog('frmChild.aspx?val=' + document.all('TextBox1').value + ',window,'dialogWidth:470px;dialogHeight:300px;scroll:no;center:yes;help:no;resizable:no;status:no');
document.all('TextBox1').value=strRetValue;//得到frmChild.aspx中传回来的值
//var strArr=strRetValue;//如果要将返回值转成数组
//var arr=strArr.split("|");
// alert(arr[0]); alert(arr[1]); ......
}
<a href="javasrcript:open();"> click to select data from datagrid1</a>
相关文章推荐
- JS窗口问题处理:使弹出窗口保持前端显示的几种方法,及window窗体对象open()和showModalDialog()用法
- js实现datagrid 模板列中有多个checkbox 时只许选中一个..........
- ASP.NET DATAGRID中如何点击整列或模板列后弹出窗口并选中新窗口数据将值返回给模板列中的文本框
- JS向右弹出DIV,点击可向左隐藏。我用jquery可以从左下角像右上角隐藏,怎么从做向右隐藏呢?
- js弹出窗体 关闭 刷新 返回值问题
- javascript关闭弹出窗体时刷新父窗体和居中显示弹出窗
- JS 怎么控制 checkbox 选中
- JS弹出框显示乱码怎么解决
- js实现跨窗体屏幕锁定并弹出对话框
- 怎样用JS获取DataGrid中CheckBox是否选中,并且取得该行的DataGrid数据?
- js弹出窗体选取Gridview中多行数据
- 怎样用JS获取DataGrid中CheckBox是否选中,并且取得该行的DataGrid数据?
- 如何将弹出层的数据通过JS传回父页面
- 解决js向jsp传中文出现乱码的问题(对弹出窗体也有效)
- DataGrid:鼠标移动行变色、单击行弹出提示窗体
- ASP.NET页面使用JS弹出窗体
- 有模式弹出子窗体,关闭时刷新父窗体
- JS 判断 Radio 单选按钮是否为选中状态 并弹出 值信息
- js入门·移动窗体/弹出提示
- JS弹出模式提示窗体,实现页面其他地方不可编辑效果