GreyBox应用中父子页面怎样实现参数传递
如题,实现在子页面输入文本显示到父页面中
代码:
父页面
- HTML code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"><title></title> <script type="text/javascript" language="javascript"> var GB_ROOT_DIR = "./greybox/"; </script> <script type="text/javascript" src="greybox/AJS.js"></script> <script type="text/javascript" src="greybox/AJS_fx.js"></script> <script type="text/javascript" src="greybox/gb_scripts.js"></script> <link href="greybox/gb_styles.css" rel="stylesheet" type="text/css" media="all" /></head><body> <form id="form1" runat="server"> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> </form></body></html>
- C# code
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;public partial class Default2 : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { this.TextBox1.Attributes.Add("onclick", "return GB_showCenter('我要输入的文本', '../Default3.aspx',400,600)"); }}子页面
- HTML code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title> </title>
<script type="text/javascript">
function reloadpage() {
parent.parent.location.reload();
parent.parent.GB_hide();
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"> </asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="显示" OnClick="Button1_Click" />
</div>
<p>
greybox子页面 </p>
<asp:Button ID="Button2" runat="server" Text="提交" OnClientClick="reloadpage()" />
<asp:Button ID="Button3" runat="server" Text="关闭" OnClientClick="javascript: window.parent.parent.GB_hide();"/>
</form>
</body>
</html>
- C# code
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;public partial class Default3 : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { Response.Write("我输入的是:" + TextBox1.Text); }}
[解决办法]
用seesion或者aa.aspx?aa=bb之类的都可以