範例一
protected void btnSubmit_Click(object sender, EventArgs e)
{
StudentInfo _objStudentInfo = new StudentInfo(Int32.Parse( txtRoll.Text) ,txtUserName.Text);
Session["objStudentInfo"] = _objStudentInfo;
ResetField();
}
protected void btnRestore_Click(object sender, EventArgs e)
{
StudentInfo _objStudentInfo = (StudentInfo) Session["objStudentInfo"];
txtRoll.Text = _objStudentInfo.Roll.ToString();
txtUserName.Text = _objStudentInfo
********************************************************************************************
範例二
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using prog_asp_net;
public partial class f7 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
prog_asp_net._S _o = new prog_asp_net._S();
Session["_s"] = _o;
Response.Write(_o._錯誤資料檔 + "1 load
");
Response.Write(_o._錯誤資料檔 + "2 load
");
}
protected void Button1_Click(object sender, EventArgs e)
{
prog_asp_net._S _a = (prog_asp_net._S) Session["_s"];
System.Web.HttpContext.Current.Response.Write("a" + _a._錯誤資料檔 + "a
");
}
}
留言列表