PreviousPage跨页面传值

ExpandedBlockStart.gif 页面1:Prev_FirstPage.aspx
<% @ Page Language = " C# "   %>

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

< script  runat ="server" >  
    public String UserName
    {
        get { 
return   this .txtName.Text; }
    }
    protected 
void  Button1_Click(object sender, EventArgs e)
    {
        Label1.Text 
=   " Postback from self. Your Name is: "   +  txtName.Text;
    } 
</ script >

< html  xmlns ="http://www.w3.org/1999/xHTML" >
< head  runat ="server" >
    
< meta  content ="text/JScript"  http-equiv ="content-script-type"   />
    
< title > First Page </ title >
</ head >
< body >
    
< form  id ="form1"  runat ="server" >
        
< div >
            
< h3 >
                The Frist Page
</ h3 >
            Your Name:
            
< asp:TextBox  ID ="txtName"  runat ="server"   />
            
< asp:Label  ID ="Label1"  runat ="server"  EnableViewState ="False"   />< br  />
            
< br  />
            
< asp:Button  ID ="Button1"  runat ="server"  Text ="Postback to Same Page"
                     OnClick
="Button1_Click"   />< br  />
            
< br  />
            
< asp:Button  ID ="Button2"  runat ="server"  Text ="Postback to Second Page"
                     PostBackUrl
="Prev_SecondPage.aspx"   />< br  />
        
</ div >
    
</ form >
</ body >
</ html >


ExpandedBlockStart.gif 页面2:Prev_SecondPage.aspx
<% @ Page Language = " C# "   %>

<% @ PreviousPageType VirtualPath = " Prev_FirstPage.aspx "   %>
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
>

< script  runat ="server" >  
    protected 
void  Page_Load(object sender, EventArgs e)
    {
        
this .Label1.Text  =   " Your Name is : "   +  PreviousPage.UserName;
    } 
</ script >

< html  xmlns ="http://www.w3.org/1999/xHTML" >
< head  runat ="server" >
    
< title > Second Page </ title >
</ head >
< body >
    
< form  id ="form1"  runat ="server" >
        
< div >
            
< h1 >
                This is the Second Page
</ h1 >
            
< p >
                
< asp:Label  ID ="Label1"  runat ="server" ></ asp:Label ></ p >
        
</ div >
    
</ form >
</ body >
</ html >


 

转载于:https://www.cnblogs.com/hejunrex/archive/2010/01/21/1653019.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值