1、get方式

发送页

<form id="form1" runat="server">
    <div>
        <a href="WebForm2.aspx?name=5">调转到Form2</a>
        <asp:Button ID="button2" Text="跳转页面" runat="server" onclick="button2_Click"/>
    </div>
</form>

protected void button2_Click(object sender, EventArgs e)
        {
            Response.Redirect("WebForm2.aspx?name=5");

}

接受页

     this.Label1.Text = Request["name"];
            //this.Label2.Text = Request.Params["name"];
            //this.Label3.Text = Request.QueryString[0];

2、post方式

a\不带 runat="server"形式

发送页

<form id="form2" action="WebForm2.aspx" method="post">
        <input name="txtname" type="text" value="lilili"  />
        <input type="submit" value="提交网页" />
</form>

接受页

  this.Label1.Text =Request.Form["txtname"];

b\带 runat="server"

发送页

<form runat="server" id="form3">
        <input id="btnTransfer" type="button" onclick="post();" runat="server" value="跳转" />
    </form>
    <form id="form4" method="post">
        <input type="text" runat="server" id="txtname" value="lili" />
    </form>
    <script type="text/javascript">
        function post() {
            form4.action = "WebForm2.aspx";
            form4.submit();
        }
    </script>

接受页

  this.Label1.Text =Request.Form["txtname"];

3、Session 和 Application

Session["name2"] = "sessontest";
            Application["name3"] = "applicationtest";

this.Label2.Text =(string)Session["name2"];
            this.Label3.Text =(string)Application["name3"];

4、静态变量

发送页

public static string statest="static string";

protected void button2_Click(object sender, EventArgs e)
        {
            Server.Transfer("WebForm2.aspx");
        }

接受页

  this.Label1.Text = WebForm1.statest;

5、Context.Handler 获取控件

发送页

          <asp:TextBox ID="TextBox1" runat="server" Text="lilili"></asp:TextBox>
        <asp:Button ID="button2" Text="跳转页面" runat="server" onclick="button2_Click"/>

          protected void button2_Click(object sender, EventArgs e)
        {
            Server.Transfer("WebForm2.aspx");
        }

  

接受页

         //获取post传过来的对象
            if (Context.Handler is WebForm1)
            {
                WebForm1 poster = (WebForm1)Context.Handler;
                this.Label1.Text = ((TextBox)poster.FindControl("TextBox1")).Text;
            }

6、Context.Handler 获取公共变量

发送页

     public string testpost = "testpost";
        protected void button2_Click(object sender, EventArgs e)
        {
            Server.Transfer("WebForm2.aspx");
        }

接受页

        //获取post传过来的对象
            if (Context.Handler is WebForm1)
            {
                WebForm1 poster = (WebForm1)Context.Handler;
                this.Label2.Text = poster.testpost;
            }

7、Context.Items 变量

发送页

protected void button2_Click(object sender, EventArgs e)
        {
            Context.Items["name"] = "contextItems";
            Server.Transfer("WebForm2.aspx");
        }

接受页

       //获取post传过来的对象
            if (Context.Handler is WebForm1)
            {
                this.Label3.Text = Context.Items["name"].ToString();
            }

WebForm aspx页面传值---7种方式的更多相关文章

  1. ios 页面传值4种方式(一) 之全局变量

    通用的是用代理的方式实现页面传值,但是有时候利用其它方式也可以很巧妙的解决问题,页面传值一共有4种方式: 1.使用全局变量, SharedApplication,定义一个变量来传递. 2.使用文件,或 ...

  2. 【页面传值6种方式】- 【JSP 页面传值方法总结:4种】 - 【跨页面传值的几种简单方式3种】

    阅读目录 1. URL 链接后追加参数 2. Form 3. 设置 Cookie 4. 设置 Session JSP 页面间传递参数是项目中经常需要的,这应该算是 web 基本功吧. 试着将各种方式总 ...

  3. ios 页面传值4种方式(四) 之通过delegate(代理)

    这是ios里最常用的设计模式了,简直贯穿了整个cocoa touch框架.废话不多说,直接上代码: 场景是: A--打开--B; B里输入数值,点击--返回--A; A里显示B输入的值; △在开始写之 ...

  4. .net cs后台刷新aspx页面的四种方式

    一:Response.Redirect(Request.Url.ToString()); 二:Response.Write("<script language=javascript&g ...

  5. WebForm.aspx 页面通过 AJAX 访问WebForm.aspx.cs类中的方法,获取数据

    WebForm.aspx 页面通过 AJAX 访问WebForm.aspx.cs类中的方法,获取数据 WebForm1.aspx 页面 (原生AJAX请求,写法一) <%@ Page Langu ...

  6. 网络笔记01-3 socket 实现百度页面的两种方式

    scoket 实现百度页面的两种方式: 1.利用系统自带    //1.创建URL NSURL *url=[NSURL URLWithString:@"http://m.baidu.com& ...

  7. WebView加载页面的两种方式——网络页面和本地页面

    WebView加载页面的两种方式 一.加载网络页面 加载网络页面,是最简单的一种方式,只需要传入http的URL就可以,实现WebView加载网络页面 代码如下图: 二.加载本地页面 1.加载asse ...

  8. WebForm.aspx 页面通过 AJAX 访问WebForm.aspx.cs类中的方法,获取数据(转)

    WebForm.aspx 页面通过 AJAX 访问WebForm.aspx.cs类中的方法,获取数据 WebForm1.aspx 页面 (原生AJAX请求,写法一) <%@ Page Langu ...

  9. Controller传值到前端页面的几种方式

    一丶追加字符串传值 #region 02-追加字符串传值 /// <summary> /// 02-追加字符串传值 /// </summary> /// <returns ...

随机推荐

  1. javascript选择排序

    function selectionSort(arr){ var index,value; for(var i = 0;i < arr.length;i ++){ index = i; //先记 ...

  2. MYSQL数据库日志和mysqlbinlog相关

    mysql有4种不同的日志,分别是二进制日志,查询日志,慢查询日志和错误日志,这些日记记录着数据库工作的方方面面,可以帮助我们了解数据库的不同方面的踪迹,下面介绍二进制日志的作用和使用方法. 1.二进 ...

  3. 《数据结构》2.3单链表(single linked list)

    //单链表节点的定义 typedef struct node { datatype data; struct node *next; }LNode,*LinkList; //LNode是节点类型,Li ...

  4. JavaScript 闭包系列一

    一. 闭包的概念 闭包是有权访问另一个函数作用域中的变量的函数. 如下代码:根据变量作用域,函数outer中所有的局部变量对函数inner都是可见的.但是反过来不行,inner内部的局部变量对oute ...

  5. i7 4790 z97-ar ssd 固态硬盘 装机的一些经历

    今天电脑终于装好了,我于七夕情人节前后的几天配了一台台式机用开发,期间遇到了一些问题与大家分享一下,希望对一些朋友有帮助. 1 买HIMD线,各个零件全部组装好后,我意识到一个问题没买HIMD线,我的 ...

  6. jdbc escape

    假如有这样1个查询请求,模糊查询标题中包含a%b_cc’d的记录,正确的sql应该是下面这样的:      select * from t_sch_work_info t where  t.title ...

  7. JQuery 判断不同浏览器

    if($.browser.msie) {          //IE浏览器alert("this is msie"); } else if($.browser.safari)   ...

  8. 更新centos curl

    centos curl 默认使用nss,而不是openssl 升级curl让curl支持openssl rpm -Uvh http://www.city-fan.org/ftp/contrib/yum ...

  9. Disable testSuite and testCase on some environment

    def testEnv = context.expand('${#Project#testEnv}') String[] testCases = ["CheckEARouting(ADS)A ...

  10. python简单文件操作

    写软件著作申请,需要将所有源代码代码贴入一个word中,在源代码前后要添加一些标记,如下: //////////////////////////// //filename1 ///////////// ...