zoukankan      html  css  js  c++  java
  • PreviousPage跨页面传值

    页面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>


    页面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>


  • 相关阅读:
    爬虫 爬取糗事百科热门板块的信息
    爬虫 爬取豆瓣高分电影信息
    django model之Meta选项
    ubuntu下无法获得锁 /var/lib/apt/lists/lock – open (11: 资源暂时不可用)
    django 通过数据库表名获取app名
    JS自定义字符串格式化函数
    django 制作上传图片并预览的效果
    Django序列化
    Django以ajax方式提交form
    Manjaro20 Linux安装VS Code
  • 原文地址:https://www.cnblogs.com/hejunrex/p/1653019.html
Copyright © 2011-2022 走看看