标题: ASP.NET 2.0功能扩展:跨页提交 [打印本页] 作者: ajax 时间: 2007-12-10 21:52 标题: ASP.NET 2.0功能扩展:跨页提交 ASP.NET 2.0,它的功能有所扩展,能够允许跨页提交。标准HTML表单(form元素)允许你向另外一个页面或者应用程序传递和发送数据信息,方法是使用表单元素。在ASP.NET 1.x中,网页则利用投递机制,把页面数据提交给该页本身。下面就让我们来探讨这个新特性:
以下是引用片段:
<%@ Page language="vb" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html><head>
<title>Cross Postback Example 2</title>
</head><body>
<script language="vb" runat="server">
Sub Page_Load()
If Not (Page.PreviousPage Is Nothing) Then
If Not (Page.IsCrossPagePostBack) ThenResponse.Write("Name:" + CType(PreviousPage.FindControl("txtName"), TextBox).Text + "<BR>")Response.Write("E-mail:" + CType(PreviousPage.FindControl("txtE-mailAddress"), TextBox).Text + "<BR>")
End If
End If
End Sub
</script>
</body>
</html>
以下是引用片段:
<%@ Page language="vb"%>
<%@ Reference Page="~/CrossPostback1.aspx" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
<title>Cross Postback Example 3</title>
</head><body>
<script language="vb" runat="server">
Sub Page_Load()
Dim cppPage As CrossPostback1_aspx
If Not (Page.PreviousPage Is Nothing) Then
If Not (Page.IsCrossPagePostBack) Then
If (Page.PreviousPage.IsValid) ThencppPage = CType(PreviousPage, CrossPostBack1_aspx)Response.Write("Name:" + cppPage.Name + "<br>")Response.Write("E-mail:" + cppPage.E-mailAddress)
End If
End If
End If
End Sub
</script>
</body>
</html>