父窗体A打开
子窗体B,然后
子窗体B在打开
窗体C(那窗体C就算是窗体B的子窗体了),请问子窗体C该如何向窗体B传值?
具体代码:
1、父窗体A:
2、子窗体B:
3、孙子窗体C:
具体代码:
1、父窗体A:
-
C# code
-
this .Button1.Attributes.Add( " onclick " , " window.showModalDialog('子窗体B.aspx','window','dialogWidth:880px;DialogHeight=600px;status:no;help:no;resizable:yes;');window.location='#'; " );
2、子窗体B:
-
HTML code
-
< script type ="text/javascript" > function XuanZe() { window.open( ' 孙子窗体C.aspx ' , ' newwindow ' , ' height=300,width=500,top= ' + (screen.AvailHeight - 300 ) / 2+',left='+(screen.AvailWidth-300) / 2 + ' ,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no ' ); } </ script > < asp:TextBox ID ="TextBox3" runat ="server" Width ="200px" ></ asp:TextBox > < input id ="Button3" type ="button" value ="选择" onclick ="XuanZe()" />
-
C# code
-
TextBox3.Text = Request.QueryString[ " id " ].ToString();
3、孙子窗体C:
-
C# code
-
protected void GridView1_RowDataBound( object sender, GridViewRowEventArgs e) { // 鼠标双击事件 if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes.Add( " onDblClick " , " javascript:window.opener.location.href='子窗体B.aspx?id= " e.Row.Cells[ 1 ].Text.ToString() + " ';window.close(); " ); } }
说明:e.Row.Cells[1].Text.ToString()获取的值是"中文",但我加上Server.UrlEncode()后还是又问题,请问可以这样传值嘛?如果不行?该怎么传值.....
答案:
e.Row.Attributes.Add("onDblClick", "javascript:window.opener.document.getElementById('TextBox3').value=" e.Row.Cells[1].Text.ToString() + ";window.close();");
|