本文来自:http://www.adminxiazai.com/article/web/net/3610.html

一种是:?传值:

第一个页面:

 Response.Redirct("default2?id=yezihack");

第二个页面得值:

 Request.QueryString("id");

-----------------------------------------

二种是:PostBackUrl

第一页面

protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.TextBox1.Text = "fjksalj";

        }
        if (Page.IsCrossPagePostBack)
        {
            this.TextBox1.Text = this.TextBox1.Text;
        }
    }

按扭属性找到postBackUrl,写入要去哪个页面

----

第二个页面

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Page.PreviousPage != null)
        {
            if (PreviousPage.IsCrossPagePostBack)
            {
               this.Label1.Text= ((TextBox)PreviousPage.FindControl("TextBox1")).Text;
            }
        }
    }

------------------------------

第三种是:Session ,cookie,Application

cookie用法:

存值:

string ss = this.TextBox1.Text;
        if (this.CheckBox1.Checked)
        {
            HttpCookie hc = new HttpCookie("user", ss);
            hc.Expires.AddDays(1);
            Response.Cookies.Add(hc);

        }

---

取值:
            if (Request.Cookies["user"] != null)
            {
                this.TextBox2.Text = Request.Cookies["user"].Value.ToString();
            }
       -----------------------

Session和Application

存值:

session["u"]=值;

Application["A"]=值;

取值:

session["u"].Tostring();

Application["A"].Tostring();

-

posted on 2011-10-18 10:51  夏麦宜  阅读(194)  评论(0编辑  收藏  举报