zoukankan      html  css  js  c++  java
  • [asp.net] 页面传值方法小记

    两个网页1.aspx和2.aspx,为第二个网页传值;
    第一种方法用Session传值:


    在1.aspx中:
    this.Session["number"]=this.TextBox.Text;
    Response.redirect("2.aspx");


    在2.aspx中让Session输出:
    if(this.session["number"]!=null)
    this.Lable.Text=this.Session["number"];


    第二种方法用Response.Redirect()传值(不提倡使用):


    在1.aspx中:
    this.Response.Redirect("2.aspx?name",this.TextBox.Text);
    在2.aspx中:
    if(this.response.querystring["name"]!=null)
    this.Lable.Text=This.Response.querystring["name"];




    第三种方法用cookies方法:


    在1.aspx中定义一cookies为它赋值:
    httpcookies cookie=new httpcookies("name");
    cookie.value=this.textbox.text;
    reponse.cookies.add(cookie);
    response.redirect("2.aspx");


    在2.aspx的输出:
    if(request.cookies["name"]!=null)
    Lable.text=request.cookies["name"].value

  • 相关阅读:
    1.Apache与Tomcat
    jeeplus 多选框
    GIT 回滚
    jsp 中data 转换 字符串
    Pattern和Matcher中表达式
    web.xml 详细介绍
    $.ajax()方法详解
    My 2016
    如何做好一个保安队长。
    集合之WeakHashMap
  • 原文地址:https://www.cnblogs.com/ishibin/p/2374855.html
Copyright © 2011-2022 走看看