Session["temp"]="aaa"; //给Session["temp"]赋值然后访问Session["temp"].ToString()就可以得到值。看看帮助
ms-help://MS.NETFrameworkSDK.CHS/cpref/html/frlrfSystemWebUIPageClassSessionTopic.htm
ms-help://MS.NETFrameworkSDK.CHS/cpref/html/frlrfSystemWebUIPageClassSessionTopic.htm
在PageLoad中先生成一个ViewState
if(!IsPostBack)
{
this.ViewState.Add("myInt",0);
}
在设置这个值的时候用
this.ViewState["myInt"]=1000;
在下次读取的时候用
a=(int)this.ViewState["myInt"];