会员
周边
众包
新闻
博问
闪存
赞助商
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
netwom
唯有务实的精神才能创造出优质产品,唯有优质产品与高效服务才能为客户创造最大价值,唯有创新才是企业长久发展之根本!—红铃铛软件
博客园
首页
新随笔
联系
订阅
管理
AJAX实时刷新数据、状态显示、局部刷新示例
function SetMessage() { _Default.GetServiceStatus(GetMessage_CallBack); }
<%
@ Page Language
=
"
C#
"
AutoEventWireup
=
"
true
"
CodeFile
=
"
Default.aspx.cs
"
Inherits
=
"
_Default
"
%>
<!
DOCTYPE html PUBLIC
"
-//W3C//DTD XHTML 1.0 Transitional//EN
"
"
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
"
>
<
html xmlns
=
"
http://www.w3.org/1999/xhtml
"
>
<
head runat
=
"
server
"
>
<
title
>
Untitled Page
</
title
>
<
script language
=
Javascript
>
function SetMessage()
{
_Default.GetServiceStatus(GetMessage_CallBack);
}
function GetMessage_CallBack(response)
{
var btn
=
document.getElementById(
'
<%=btnSet.ClientID%>
'
);
var btnPanel
=
document.getElementById(
'
btnPanel
'
);
var lbl
=
document.getElementById(
'
lblStatus
'
);
var status
=
response.value;
switch
(status)
{
case
"
Running
"
:
lbl.innerText
=
"
运行中
"
;
btn.value
=
"
停止
"
;
btnPanel.style.visibility
=
"
visible
"
;
break
;
case
"
Stopped
"
:
lbl.innerText
=
"
已停止
"
;
btn.value
=
"
启动
"
;
btnPanel.style.visibility
=
"
visible
"
;
break
;
case
"
StartPending
"
:
lbl.innerText
=
"
正在启动
"
;
btnPanel.style.visibility
=
"
hidden
"
;
break
;
case
"
StopPending
"
:
lbl.innerText
=
"
正在停止
"
;
btnPanel.style.visibility
=
"
hidden
"
;
break
;
}
}
</
script
>
</
head
>
<
body onload
=
"
setInterval('SetMessage()',100);
"
>
<
form id
=
"
form1
"
runat
=
"
server
"
>
<
table
>
<
tr
><
td width
=
"
250
"
><
div id
=
"
lblStatus
"
></
div
></
td
><
td
>
<
div id
=
"
btnPanel
"
style
=
"
visibility:visible
"
><
asp:Button ID
=
"
btnSet
"
runat
=
"
server
"
Text
=
"
Button
"
OnClick
=
"
btnSet_Click1
"
/></
div
></
td
></
tr
>
</
table
>
</
form
>
</
body
>
</
html
>
protected
void
Page_Load(
object
sender, EventArgs e)
{
Ajax.Utility.RegisterTypeForAjax(
typeof
(_Default));
}
[Ajax.AjaxMethod()]
public
string
GetServiceStatus()
{
return
ctl.Status.ToString();
}
发表于
2007-11-05 22:28
netwom
阅读(
2310
) 评论(
0
)
编辑
收藏
举报
会员力量,点亮园子希望
刷新页面
返回顶部
公告
不经一翻寒彻骨,哪得梅花扑鼻香 | 工作也是生活,朋友们些多保重身体!