asp.net 2.0中的Cross PAGE REQUEST
2005-01-15 20:12
387 查看
大家还记得吧,在ASP中,一个页面里,只要有一个Form表单,在POST后,就可以在
另外一个表单里用REQUEST来接受了,而在ASP.NET 2.0中,咱们又可以这样做了,因为有了
新的特性,叫做cross page request,可以实现这样的功能,代码如下,十分简单:
crosspage1.aspx:
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" Runat="server"></asp:TextBox>
<asp:Button ID="Button1" Runat="server" Text="Button" PostBackUrl="crosspage2.aspx" />
</div>
</form>
</body>
</html>
crosspage2.aspx:
public void Page_Load()
{
if (PreviousPage != null && PreviousPage.IsCrossPagePostBack)
{
TextBox textBox1 = PreviousPage.FindControl("TextBox1") as TextBox;
if (textBox1 != null)
Response.Write(textBox1.Text);
}
}
哈哈,明白了吧?其中,我们利用button,linkbutton等控件的postbackurl属性,可以指定要将内容POST到哪一个表单中去,而在要接受内容的页面中,使用PreviousPage.findconrol的方法,就可以接受前一个页面中控件的内容了。
另外一个表单里用REQUEST来接受了,而在ASP.NET 2.0中,咱们又可以这样做了,因为有了
新的特性,叫做cross page request,可以实现这样的功能,代码如下,十分简单:
crosspage1.aspx:
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" Runat="server"></asp:TextBox>
<asp:Button ID="Button1" Runat="server" Text="Button" PostBackUrl="crosspage2.aspx" />
</div>
</form>
</body>
</html>
crosspage2.aspx:
public void Page_Load()
{
if (PreviousPage != null && PreviousPage.IsCrossPagePostBack)
{
TextBox textBox1 = PreviousPage.FindControl("TextBox1") as TextBox;
if (textBox1 != null)
Response.Write(textBox1.Text);
}
}
哈哈,明白了吧?其中,我们利用button,linkbutton等控件的postbackurl属性,可以指定要将内容POST到哪一个表单中去,而在要接受内容的页面中,使用PreviousPage.findconrol的方法,就可以接受前一个页面中控件的内容了。
相关文章推荐
- asp.net 2.0中的Cross PAGE REQUEST
- asp.net 2.0中的Cross PAGE REQUEST
- asp.net 2.0中的Cross PAGE REQUEST
- asp.net 2.0中的Cross PAGE REQUEST
- asp.net 2.0中的gridview里用crosspage的功能
- cross-page posting in ASP.NET 2.0
- asp.net 2.0中的gridview里用crosspage的功能
- Cross page posting in ASP.NET 2.0
- asp.net 2.0中的gridview里用crosspage的功能
- asp.net 2.0中的gridview里用crosspage的功能
- Cross-Page WebPart Connections with ASP.NET 2.0
- [ASP.NET学习笔记之十二]ASP.NET 2.0中Theme、MasterPage和代码国际化
- asp.net 2.0中的MaxPageStateFieldLength 属性
- ASp.NET 2.0中Page事件的执行顺序
- [转]ASP.NET AJAX and Sys.Webforms.PageRequestManagerServerErrorException
- Asp.net 2.0专题之一:MasterPage
- Asp.net MVC 3 防止 Cross-Site Request Forgery (CSRF)原理及扩展 安全 注入
- 调试ASP.NET 2.0 HttpException请求超时(Request timed out)
- 关于Asp.net中Page.IsCrossPagePostBack的使用
- ASP.NET 2.0 之 Master Page 学习笔记