zoukankan      html  css  js  c++  java
  • B/S结构中页面间的传值

    常见的页面间的传值有session,cookie,application,server.transfer(),queryString,今天主要记录一下server.transfer()的用法。

    从A页面Transfer到B页面时,就可以在B页面通过Context.Handler获得A页面的一个类的实例,从而在B调用A的各个成员对象。

    下面的示例建立了AA和BB, 通过Server.Transfer()方法演示在BB中读取AA的文本框、读取属性、通过Context传值、调用AA的方法等。

    AA上放置一个TextBox1程序如下: 

    public partial class AA: System.Web.UI.Page
    {

        protected void Page_Load(object sender, EventArgs e)

        {        

                    Server.Transfer("BB.aspx");

        }

        public string TxtName

       {

            get { retrun TextBox1.Text;}

         }
    }

    BB程序如下:

    public partial class BB: System.Web.UI.Page
    {

        protected void Page_Load(object sender, EventArgs e)

        {        

                 AA p=(AA)Context.Handler;

                   Response.Write("The AA TextBox1 Value is:"+p.TxtName);

        }

       }

    好了,测试正确,但别忘 了在BB页面中引入 <%@ Reference Page="AA.aspx" %>,这句话很关键,好多同志都是因为这名话调试不出来的.

  • 相关阅读:
    map映射的用法
    相似的字串(hash+二分)
    进制 /字符串 hash
    CF#632 C.Eugene and an array
    2020牛客寒假算法基础集训营6 H-云
    Educational Codeforces Round 80 (Div. 2)
    Codeforces Round #601 (Div. 2)补题
    luogu-单调队列/单调栈专题
    Comet OJ
    Comet OJ
  • 原文地址:https://www.cnblogs.com/Zouzhe/p/4060499.html
Copyright © 2011-2022 走看看