会员
周边
众包
新闻
博问
闪存
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
散步的蠕虫的 IT BLOG 慢悠悠的在IT世界里逛荡
MSN:syringa_flz@hotmail.com
读写Session
Session
//
在服务器端page_load
AjaxPro.Utility.RegisterTypeForAjax(
typeof
(test));
this
.Button_Write.Attributes.Add(
"
onclick
"
,
"
WriteSession();
"
);
//
写session
this
.Button_Read.Attributes.Add(
"
onclick
"
,
"
ReadSession();
"
);
//
读session
//
其他写和读的方法
/**/
///
<summary>
///
写session
///
</summary>
///
<param name="str"></param>
[AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
public
void
WriteSession(
string
str)
{
Session[
"
UserName
"
]
=
str;
}
/**/
///
<summary>
///
读session
///
</summary>
///
<returns></returns>
[AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
public
string
ReadSession()
{
string
str
=
""
;
if
(Session[
"
UserName
"
]
!=
null
)
{
str
=
Session[
"
UserName
"
].ToString();
}
return
str;
}
客户端代码:
//
访问Session的值
//
写入
function
WriteSession()
{
var
str
=
"
HAHA
"
;
test.WriteSession(str,CallBack_WriteSession);
}
function
CallBack_WriteSession(res)
{
if
(res.error
==
null
)
{
alert(
"
OK
"
);
}
else
{
alert(res.error.message);
}
}
//
访问
function
ReadSession()
{
test.ReadSession(CallBack_ReadSession);
}
function
CallBack_ReadSession(res)
{
if
(res.error
==
null
)
{
alert(res.value);
}
else
{
alert(res.error.message);
}
}
posted on
2006-11-04 16:02
散步的蠕虫
阅读(
197
) 评论(
0
)
编辑
收藏
举报
会员力量,点亮园子希望
刷新页面
返回顶部
导航
博客园
首页
新随笔
联系
订阅
管理