跨网页公布(Cross-Page Posting)

CrossPageSource页面,最为关键的是给Button控件设置PostBackUrl属性

 1 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CrossPageSource.aspx.cs" Inherits="CrossPagePosting.CrossPageSource" %>
 2 
 3 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 4 
 5 <html xmlns="http://www.w3.org/1999/xhtml">
 6 <head runat="server">
 7     <title></title>
 8 </head>
 9 <body>
10     <form id="form1" runat="server">
11     <div>
12     <table>
13        <tr>
14            <td><asp:Label ID="Label1" runat="server" Text="请输入姓名:"></asp:Label></td>
15            <td><asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></td>
16            <td>
17                <asp:Button ID="Button1" runat="server" Text="确定" 
18             PostBackUrl="~/CrossPageTarget.aspx" /></td>
19        </tr>
20        </table>
21     </div>
22     </form>
23 </body>
24 </html>

CrossPageTarget页面

 1 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CrossPageTarget.aspx.cs" Inherits="CrossPagePosting.CrossPageTarget" %>
 2 
 3 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 4 
 5 <html xmlns="http://www.w3.org/1999/xhtml">
 6 <head runat="server">
 7     <title></title>
 8 </head>
 9 <body>
10     <form id="form1" runat="server">
11     <div>
12        <table><tr><td>
13            <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
14        </td></tr></table>
15     </div>
16     </form>
17 </body>
18 </html>

CrossPageTarget后台

 1 using System;
 2 using System.Collections.Generic;
 3 
 4 using System.Web;
 5 using System.Web.UI;
 6 using System.Web.UI.WebControls;
 7 
 8 namespace CrossPagePosting
 9 {
10     public partial class CrossPageTarget : System.Web.UI.Page
11     {
12         protected void Page_Load(object sender, EventArgs e)
13         {
14             TextBox txtUsername = (TextBox)PreviousPage.FindControl("TextBox1");
15             //txtUsername.
16             Label1.Text = "您输入的姓名是:" + txtUsername.Text;
17         }
18     }
19 }

 

转载于:https://www.cnblogs.com/Robert-huge/archive/2012/12/10/2811351.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值