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!
    

      

  • 相关阅读:
    关于binary log一点总结[转]
    使用mysql索引技巧及注意事项
    优化php性能的一点总结
    html静态页面实现微信分享思路
    MySql字符串函数使用技巧
    Oracle计算时间差函数
    oracle10g获取Date类型字段无时分秒解决办法!
    Oracle常用函数
    COALESCE操作符
    关于null的操作
  • 原文地址:https://www.cnblogs.com/Akgu/p/5152998.html
Copyright © 2011-2022 走看看