如何传值在2个页面之间 要求不刷新父页面,并且不能用Querystring传值

待到芦花摇曳时,再倚西窗闻雁鸣,日落西山江上行,思缱绻,清月冷,风也寄情。光影斑驳,时光掠过,心于光阴的门楣,寂静欢喜。一纸素文,一缕清风,写意了心中的世界,终有一人的身影站立在风中于梦中,风去,影渐消。水潺潺,风声声,心低喃细语。 "
例子:
以下是父页的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" onclick="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"))

到此这篇关于如何传值在2个页面之间 要求不刷新父页面,并且不能用Querystring传值就介绍到这了。股票有涨有落,然而打着信心标志的股票将使你永涨无落。更多相关如何传值在2个页面之间 要求不刷新父页面,并且不能用Querystring传值内容请查看相关栏目,小编编辑不易,再次感谢大家的支持!

标签: Querystring