zoukankan      html  css  js  c++  java
  • 不同页面之间传递值

    本篇技巧和诀窍记录的是:不同页面之间传递值,非常简单的技巧,我相信大家都知道。
    
    这个场景太常见了,当然有许多许多的方法,我来介绍一种非常简单的方法吧!
    
    第一步:模拟两个页面
    
    A页面、B页面。需要在B页面获取A页面的信息。
    
    A页面:
    
    <form id="form1" runat="server">
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:Calendar ID="Calendar1" runat="server"></asp:Calendar>
        <asp:Button ID="Button1" runat="server" 
                    PostBackUrl="~/B.aspx" Text="Button" />
    </form>
    B页面:
    
    <form id="form1" runat="server">
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
        <a href="A.aspx">A.aspx</a>
    </form>
    第二步:如何获取呢
    
    来个非常简单的,在B页面Page_Load事件中使用Page.PreviousPage 属性,获取向当前页传输控件的页。 找到相应的控件。
    
    protected void  Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack) {
            TextBox t = ((TextBox)(PreviousPage.FindControl("Textbox1")));
            Calendar c = ((Calendar)(PreviousPage.FindControl("Calendar1")));
            Label1.Text = string.Format("文本框:{0},选择日期?:{1}", 
                                             t.Text, c.SelectedDate);
        }
    }
    OK!
    

      

  • 相关阅读:
    poj 1634
    poj 2153
    POJ 1693
    poj 1789
    POJ 2676
    vue 路由
    用 node.js 创建第一个Hello World
    js原生Ajax 的封装和原理
    BFC原理
    怎么理解js的面向对象编程
  • 原文地址:https://www.cnblogs.com/Akgu/p/5152998.html
Copyright © 2011-2022 走看看