代码分4个页面:
show.aspx这里为接收下面三个页面传递变量用的。
redirect.aspx
execute.aspx
transfer.aspx
这三个分别用相应方法进行传递。
代码如下:
redirect.aspx:
<%--测试redirect、execute、transfer三个方法对变量的传递--%>

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

Sub page_load()Sub page_load(ByVal sender As Object, ByVal e As EventArgs)
Dim cook As String
cook = "Redirect传递的小甜饼"
Response.Cookies("cook").Value = cook
Response.Redirect("show.aspx")
End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>edirect页面</title>
</head>
<body>
<form id="edirect页面" runat="server">
<div>
Redirect页面
</div>
</form>
</body>
</html>
Execute.aspx:
<%--测试redirect、execute、transfer三个方法对变量的传递--%>

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

Sub page_load()Sub page_load(ByVal sender As Object, ByVal e As EventArgs)
Dim cook As String
cook = "Execute传递的小甜饼"
Response.Cookies("cook").Value = cook
Server.Execute("show.aspx")
End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Execute页面</title>
</head>
<body>
<form id="Execute页面" runat="server">
<div>
Execute页面
</div>
</form>
</body>
</html>
Transfer.aspx:
<%--测试redirect、execute、transfer三个方法对变量的传递--%>

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

Sub page_load()Sub page_load(ByVal sender As Object, ByVal e As EventArgs)
Dim cook As String
cook = "Transfer传递的小甜饼"
Response.Cookies("cook").Value = cook
Server.Transfer("show.aspx")
End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Transfer页面</title>
</head>
<body>
<form id="Transfer页面" runat="server">
<div>
Transfer页面
</div>
</form>
</body>
</html>
show.aspx:
<%--测试redirect、execute、transfer三个方法对变量的传递--%>

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

Sub page_load()Sub page_load(ByVal sender As Object, ByVal e As EventArgs)
message.text = Response.Cookies("cook").Value
End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>show页面</title>
</head>
<body>
<form id="show页面" runat="server">
<asp:label ID ="message" runat="server" />
</form>
</body>
</html>
大家调试一下看结果。
Execute.aspx调用时,会传递COOKIC并显示自己HTML内的代码,因为他传递变量并且执行后返回。
redirect.aspx调用时,什么也不显示,因为他不传递变量,也不返回。
transfer.aspx调用时,只传递变量不返回。
show.aspx这里为接收下面三个页面传递变量用的。
redirect.aspx
execute.aspx
transfer.aspx
这三个分别用相应方法进行传递。
代码如下:
redirect.aspx:






























Execute.aspx:





























Transfer.aspx:





























show.aspx:























大家调试一下看结果。
Execute.aspx调用时,会传递COOKIC并显示自己HTML内的代码,因为他传递变量并且执行后返回。
redirect.aspx调用时,什么也不显示,因为他不传递变量,也不返回。
transfer.aspx调用时,只传递变量不返回。