GridView子窗口向父窗口传值问题?
来源:互联网 发布:泉州网络电视台 编辑:程序博客网 时间:2024/05/16 05:56
一.子窗体向父窗体传值
1、父窗体:
<script type="text/javascript">
function XuanZeContract()
{
window.showModalDialog('子窗体.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');
}
父窗体后台取值:
TextBox1.Text = Request.QueryString["id"];
HTML code:
<input id="Button3" type="button" value="选择" onclick="XuanZeContract()" />
2、子窗体后台双击选择:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
//鼠标双击事件
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onDblClick", "javascript:opener.location.href='父窗体.aspx?id=" + e.Row.Cells[1].Text.ToString() + "';window.close();");
}
}
二、现在又是父窗体向子窗体传值
1、父窗体:
<ItemTemplate>
<asp:LinkButton ID="LinkButton5" runat="server" ForeColor="#000066">查看</asp:LinkButton>
<asp:Label ID="Label2" runat="server"
Text='<%#DataBinder.Eval(Container.DataItem, "F_name")%>' Visible="False" Width="0px"></asp:Label>
</ItemTemplate>
C# code
if (e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton l = (LinkButton)e.Row.FindControl("LinkButton5");
Label b = (Label)e.Row.FindControl("Label2");
string Temp = b.Text.ToString();
l.Attributes.Add("onclick", "window.showModalDialog('ContractParticularData.aspx?id="+Server.UrlEncode(Temp)+"','window','dialogWidth:880px;DialogHeight=700px;status:no;help:no;resizable:yes;');window.location='#';");
}
2、子窗体:
HTML code
<tr>
<td class="style3">客户名称:</td>
<td class="style1">
<asp:Label ID="Label3" runat="server" Text="Label3"></asp:Label>
</td>
</tr>
C# code
string IDStr = Request.QueryString["id"].ToString();
OleDbConnection sqlConn = DB.CreateConn();
sqlConn.Open();
string sqlStr = "select * from XXXX where F_name='" + IDStr.ToString() + "'";
OleDbCommand MyCommand = new OleDbCommand(sqlStr, sqlConn);
OleDbDataReader MyReader = MyCommand.ExecuteReader();
while(MyReader.Read())
{
this.Label3.Text = MyReader["XXX"].ToString();
}
sqlConn.Close();
三、
现在的问题是,父窗体A打开子窗体B,然后子窗体B在打开窗体C(那窗体C就算是窗体B的子窗体了),请问子窗体C该如何向窗体B传值?
1、父窗体A:
this.Button1.Attributes.Add("onclick", "window.showModalDialog('子窗体B.aspx','window','dialogWidth:880px;DialogHeight=600px;status:no;help:no;resizable:yes;');window.location='#';");
2、子窗体B:
<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:
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.Attributes.Add("onDblClick", "javascript:window.opener.documentById('txt').value='"+e.Row.Cells[1].Text.ToString() + "';window.close();");
}
}
四、用window.open(),window.showModalDialog()打开页面的区别应用
a.用window.open()打开子窗口的传参方法
a.html
HTML code
<html>
<body>
要传的值
<input type='text' id='txtID' name='txtName' value='aa' /> <br>
<input type='button' value='open' onclick="window.open('b.html');" />
<script>
alert('刷新了页面');
function method()
{
alert('a.html');
}
</script>
</body>
</html>
b.html
HTML code
<html>
<script>
function getValue()
{
//document.getElementById('txt').value=window.opener.txtName.value;
document.getElementById('txt').value=window.opener.document.getElementById('txtID').value;
}
</script>
<body onload='getValue();'>
传过来的值是
<input type='text' id='txt' />
<input type='button' value='调用父窗口的方法' onclick='window.opener.method();' />
<br>
<br>
<br>
设置父窗口的文本<input type='text' id='t' />
<input type='button' value='执行'
onclick='window.opener.document.getElementById("txtID").value=document.getElementById("t").value;' />
<br>
<br>
<input type='button' value='刷新父窗口' onclick='window.opener.location=window.opener.location;' />
<br>
<br>
<input type='button' value='关闭父窗口' onclick='window.opener.close();opener=null;' />
</body>
</html>
b,用window.showModalDialog()打开窗口的传参方法c.htmlHTML code
<html>
<script>
function getValue()
{
if(window.dialogArguments)
{
document.getElementById('txt').value=window.dialogArguments.document.getElementById('txtID').value;
}
}
</script>
<body onload='getValue();'>
传过来的值是
<input type='text' id='txt' />
<input type='button' value='调用父窗口的方法' onclick='window.dialogArguments.method();' />
<br>
<br>
<br>
设置父窗口的文本<input type='text' id='t' />
<input type='button' value='执行'
onclick='window.dialogArguments.document.getElementById("txtID").value=document.getElementById("t").value;' />
<br>
<br>
<input type='button' value='刷新父窗口' onclick='window.dialogArguments.location=window.dialogArguments.location;' />
<br>
<br>
<input type='button' value='关闭父窗口' onclick='window.dialogArguments.close();' />
</body>
</html>
- GridView子窗口向父窗口传值问题?[
- GridView子窗口向父窗口传值问题?
- gridview子窗口向父窗口传值!
- GridView子窗口向父窗口传值刷新
- 子窗口向父窗口传值
- 子窗口向父窗口传值
- 子窗口 向父窗口传值
- C#窗口间传值一例(子窗口向父窗口传值
- C#窗口间传值一例(子窗口向父窗口传值)
- 子窗口向父窗口传数据
- 父窗口向子窗口传指针
- 子窗口向父窗口傳值
- 父窗口向子窗口传递值
- Javascript实现子窗口向父窗口传值(转)
- JS子窗口向父窗口传值
- c# 父窗口向子窗口传值
- JS子窗口向父窗口传值
- JS 父窗口向子窗口传值问题(window.open())
- MDI窗体设计中,避免重复打开同一个子窗体——详解
- Linux RHEL-AS4完美加入win2k8 R2 AD域
- zookeeper学习1
- 单链表
- 关于输入法改变而引起的自适应问题
- GridView子窗口向父窗口传值问题?
- zookeeper学习2
- zookeeper学习3
- AspectJ 文章
- 使用winsock+UDP写的一个简单接收端程序
- Socket & Select
- 导航栏显示隐藏简单处理
- 剑破冰山:Oracle开发艺术——ITPUB一线巨制(1)
- Android反编译方法的总结