现在的位置: 首页 > 综合 > 正文

asp.net 中Session和Application使用

2013年04月20日 ⁄ 综合 ⁄ 共 948字 ⁄ 字号 评论关闭

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        //Label1.Text = Request.QueryString["name"];
        //Label2.Text = Request.QueryString["email"];
        try
        {
            Label1.Text = Application["name"].ToString();
            Label2.Text = Application["email"].ToString();
            Application.Remove("name");
            Application.Remove("email");

        }
        catch
        { }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Application["name"] = TextBox1.Text;
        Application["email"] = TextBox2.Text;
        Response.Redirect(HttpContext.Current.Request.Url.PathAndQuery);

       
    }
}

//============================================

抱歉!评论已关闭.