就是在aspx.cs给session添加了一个值 如何在aspx页面中读取出来

解决方案 »

  1.   

          protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                Session["session1"] = "111";
                Session["session2"] = "222";
                Label1.Text = Session["session1"].ToString();
                Label2.Text = Session["session2"].ToString();
            }
        }
      

  2.   

    如果你是在Web.config中作的如:
    void Application_Start(object sender, EventArgs e)
    {
            Application["total"] = 0;  }在default.aspx.cs中也可以应用:
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Label1.Text = Application["total"].ToString();    }记得加分呀!
      

  3.   

    Session["session"] = "value"; 
      

  4.   

    设置
    Session["UserName"]=this.txtUname.Text; 
    读取
    this.Label1.Text=Session["UserName"].ToString();
      

  5.   

    在aspx页面用<%=Session["sessionname"]%>