c# 父窗口弹出子窗口 双击 子窗口中的一行 把值赋给父窗口的各个相应的文本框?
我的父窗口代码
<script>
var arr_fhr=new Array();
function openfhr()
{
window.showModalDialog("fhrxm.aspx ", "选择窗口",'scrollbars=no,resizable=no,top=0,left=0,width=250,height=150');
if (arr_fhr.length>0){
document.input1.fhrbm.value=arr_fhr[0];
document.input1.fhrxm.value=arr_fhr[1];
document.input1.fhrdh.value=arr_fhr[2];
document.input1.fhrdz.value=arr_fhr[3];
}
}
</script><asp:Button ID="btnfhr" runat="server" Text="..." CssClass="btn" onclick="btnfhr_Click" />子窗口fhrxm.aspx代码
<script language="javascript">
function chuan(oRow)
{
var arr_fhr=new Array();
e.Row.Cells[1].Text.ToString()
arr_fhr[0]=oRow.cells[0].innerText;
arr_fhr[1]=oRow.cells[1].innerText;
arr_fhr[2]=oRow.cells[2].innerText;
arr_fhr[3]=oRow.cells[3].innerText;
dialogArguments.arr_fhr= arr_fhr;
window.close();
}
</script> fhrxm.aspx.cs 中的 双击事件
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{ e.Row.Attributes.Add("onDblClick", "chuan(this)");
}
传不了值啊 谁给看看???
我的父窗口代码
<script>
var arr_fhr=new Array();
function openfhr()
{
window.showModalDialog("fhrxm.aspx ", "选择窗口",'scrollbars=no,resizable=no,top=0,left=0,width=250,height=150');
if (arr_fhr.length>0){
document.input1.fhrbm.value=arr_fhr[0];
document.input1.fhrxm.value=arr_fhr[1];
document.input1.fhrdh.value=arr_fhr[2];
document.input1.fhrdz.value=arr_fhr[3];
}
}
</script><asp:Button ID="btnfhr" runat="server" Text="..." CssClass="btn" onclick="btnfhr_Click" />子窗口fhrxm.aspx代码
<script language="javascript">
function chuan(oRow)
{
var arr_fhr=new Array();
e.Row.Cells[1].Text.ToString()
arr_fhr[0]=oRow.cells[0].innerText;
arr_fhr[1]=oRow.cells[1].innerText;
arr_fhr[2]=oRow.cells[2].innerText;
arr_fhr[3]=oRow.cells[3].innerText;
dialogArguments.arr_fhr= arr_fhr;
window.close();
}
</script> fhrxm.aspx.cs 中的 双击事件
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{ e.Row.Attributes.Add("onDblClick", "chuan(this)");
}
传不了值啊 谁给看看???
父窗体
Session["id"]=textBoxt.Text;
子窗体
button1的click事件中
textBox2=Seeion["id"].ToString();
var url = "../a.aspx?ToId=PId&ToName=PName";
var mwidth = "400";
var mheight = "250";
var loc_x, loc_y;
if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1) {
alert(mwidth); loc_x = parseInt((document.body.clientWidth - mwidth) / 2 + 200);
loc_y = parseInt((document.body.clientHeight - mheight) / 2);
window.open(url, "", "left=" + loc_x + "px,top=" + loc_y + "px,width=" + mwidth + "px,height=" + mheight + "px,resizable=no,scrollbars=yes,status=0");
}
else {
loc_x = document.body.scrollLeft + event.clientX - event.offsetX - 100;
loc_y = document.body.scrollTop + event.clientY - event.offsetY + 170;
window.open(url, "", "left=" + loc_x + "px,top=" + loc_y + "px,width=" + mwidth + "px,height=" + mheight + "px,resizable=no,scrollbars=yes,status=0");
//indow.showModalDialog(url, self, "edge:raised;scroll:1;status:0;help:0;resizable:0;dialogWidth:" + mwidth + "px;dialogHeight:" + mheight + "px;dialogTop:" + loc_y + "px;dialogLeft:" + loc_x + "px");
}
}
a.aspx
var p_window;
if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1)
p_window = window.parent.opener;
else
p_window = window.parent.opener; function SetValue(id, name) {
p_window.document.getElementById("hf_Id").value = id;
p_window.document.getElementById("txtName").value =name;
self.close();
}
就是你要传递的值 你拼接一下,把各个单元格的值都保存在一个字符串里面 中间用-或者/隔开。全部传递过去。
然后在父窗体中用split('-')就可以保存在 var arr_fhr=new Array(); 它里面啊、。然后JS赋值就可以了啊?
window.showModalDialog("fhrxm.aspx ", "选择窗口",'scrollbars=no,resizable=no,top=0,left=0,width=250,height=150');
其中"选择窗口"就只指带了dialogArguments会返回的变量,直接用window 表示当前页面就可以了。
所以将这句改写成:
window.showModalDialog("fhrxm.aspx ", window,'scrollbars=no,resizable=no,top=0,left=0,width=250,height=150');就可以啦。:)