1.通过Cookie,因为它既可以在服务器端对其进行操作,也可在客户端对其进行操作
但是缺点是不安全,而且有时客户端会由于安全问题禁用Cookie!
例子:
以下是父页的Html代码
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="main.aspx.vb" Inherits="zero.main"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>main</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<script language="javascript" charset="gb2312">
function searchvalue()
{
var sql="select * from companyjob";
SetCookie("SendSql",sql);
var url="child.aspx";
window.open(url,'_blank');
}
function SetCookie(name, value)
{
document.cookie = name + "=" + value;
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout" >
<form id="Form1" method="post" runat="server">
<INPUT id="Hidden1" style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 8px" type="hidden"
name="Hidden1" runat="server"><INPUT style="Z-INDEX: 102; LEFT: 96px; POSITION: absolute; TOP: 144px" type="button" οnclick="searchvalue();"
value="Open" id="Button1" name="Button1">
<asp:Button id="Button2" style="Z-INDEX: 103; LEFT: 256px; POSITION: absolute; TOP: 152px" runat="server"
Text="Button"></asp:Button>
</form>
</body>
</HTML>
child 页[子页]
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="child.aspx.vb" Inherits="zero.child"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>child</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<script language =javascript >
function getv()
{
alert(document.forms("Hidden1"));
document.all("Hidden1").value=document.forms("Hidden1");
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout" >
<form id="Form1" method="post" runat="server">
<INPUT style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 8px" type="hidden" id="Hidden1"
name="Hidden1" runat="server"></FONT>
</form>
</body>
</HTML>
.vb文件
If Not IsPostBack Then
'Response.Write(Request.Form("Hidden1"))
Dim cookie As HttpCookie = Request.Cookies("SendSql")
If Not cookie Is Nothing Then
Response.Write(cookie.Value)
End If
End If
2。是思归大哥介绍的方法
在父页中加入一个非runat=server的form表单,用来提交隐藏控件的值到子页
<form method="post" target="_blank" id="form2">
<input type=hidden name="query">
</form>
<script language="javascript">
function searchvalue()
{
var sql="select * from companyjob";
document.all.form2.query.value=sql;
document.all.form2.action="child.aspx";
document.all.form2.submit();
}
</script>
子页的后台代码中 (.vb)
在Page_Load事件中写
Response.Write(Request.Form("query"))
但是缺点是不安全,而且有时客户端会由于安全问题禁用Cookie!
例子:
以下是父页的Html代码
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="main.aspx.vb" Inherits="zero.main"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>main</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<script language="javascript" charset="gb2312">
function searchvalue()
{
var sql="select * from companyjob";
SetCookie("SendSql",sql);
var url="child.aspx";
window.open(url,'_blank');
}
function SetCookie(name, value)
{
document.cookie = name + "=" + value;
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout" >
<form id="Form1" method="post" runat="server">
<INPUT id="Hidden1" style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 8px" type="hidden"
name="Hidden1" runat="server"><INPUT style="Z-INDEX: 102; LEFT: 96px; POSITION: absolute; TOP: 144px" type="button" οnclick="searchvalue();"
value="Open" id="Button1" name="Button1">
<asp:Button id="Button2" style="Z-INDEX: 103; LEFT: 256px; POSITION: absolute; TOP: 152px" runat="server"
Text="Button"></asp:Button>
</form>
</body>
</HTML>
child 页[子页]
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="child.aspx.vb" Inherits="zero.child"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>child</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<script language =javascript >
function getv()
{
alert(document.forms("Hidden1"));
document.all("Hidden1").value=document.forms("Hidden1");
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout" >
<form id="Form1" method="post" runat="server">
<INPUT style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 8px" type="hidden" id="Hidden1"
name="Hidden1" runat="server"></FONT>
</form>
</body>
</HTML>
.vb文件
If Not IsPostBack Then
'Response.Write(Request.Form("Hidden1"))
Dim cookie As HttpCookie = Request.Cookies("SendSql")
If Not cookie Is Nothing Then
Response.Write(cookie.Value)
End If
End If
2。是思归大哥介绍的方法
在父页中加入一个非runat=server的form表单,用来提交隐藏控件的值到子页
<form method="post" target="_blank" id="form2">
<input type=hidden name="query">
</form>
<script language="javascript">
function searchvalue()
{
var sql="select * from companyjob";
document.all.form2.query.value=sql;
document.all.form2.action="child.aspx";
document.all.form2.submit();
}
</script>
子页的后台代码中 (.vb)
在Page_Load事件中写
Response.Write(Request.Form("query"))