首页 > 其他 > 详细

页面中用Context.Handler传递

时间:2017-05-05 00:31:09      阅读:343      评论:0      收藏:0      [点我收藏+]
   最近被WCF弄得身心疲惫。今天抽空看了一下页面传值的一些技巧。传统的cookie session 什么的就不介绍了
今天介绍Context的用法
首先要应用using System.Runtime.Remoting.Contexts;命名空间
public static string strname = "";
//静态变量传递
            strname = "wtyTest";
            Server.Transfer("WebFormD2.aspx");
           
            //接收页面
            string request = string.Empty;
            request = WebFormD1.strname;
  //Context.Handler获取控件     
       if (Context.Handler is WebFormE1)
            {
                //获得页面对象
                WebFormE1 poster = (WebFormE1)Context.Handler;
                //取得控件
                TextBox.Text =(TextBox)poster.FindControl("TextBox1")).Text;
            }
//Context.Handler获取公共变量
            //发送页面代码
             public static string strname = ""; 
            strname = "wtyTest";
            Server.Transfer("WebFormD2.aspx");
            
            //接收页面代码
            if (Context.Handler is WebFormE1)
            {
                //获得页面对象
                WebFormE1 poster = (WebFormE1)Context.Handler;
                TextBox.Text =poster.strname;
            }
//Context.items变量
            //发送页面代码
            Context.Items["name"]="wtytest";
            Server.Transfer("WebFormD2.aspx");
            
            //接收页面代码
            if (Context.Handler is WebFormE1)
            {
               
                //
                TextBox.Text =Context.Items["name"].ToString();
            }

页面中用Context.Handler传递

原文:http://www.cnblogs.com/zhaohongtian/p/6810381.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!