zoukankan
html css js c++ java
基于Ajax:实时刷新数据,实时显示状态,局部刷新的示例。
aspx页面:
_Default为类名称,GetServiceStatus为类中的一个方法。
<%
@ 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
>
.cs文件
protected
void
Page_Load(
object
sender, EventArgs e)
{
Ajax.Utility.RegisterTypeForAjax(
typeof
(_Default));
}
[Ajax.AjaxMethod()]
public
string
GetServiceStatus()
{
return
ctl.Status.ToString();
}
查看全文
相关阅读:
vmware 安装 centos7
Centos7 开机启动命令行模式
Get、Post 提交的乱码问题
RabbitMQ消息队列(一):详细介绍
spring boot 整合 RabbitMq (注解)
CF Tavas and Nafas
HDU 2295 Radar (DLX + 二分)
CF Drazil and Factorial (打表)
CF Drazil and His Happy Friends
CF Drazil and Date (奇偶剪枝)
原文地址:https://www.cnblogs.com/silva/p/709019.html
最新文章
[笔记-数据结构]并查集
POJ-3264 Balanced Lineup 线段树
ArchLinux 调节屏幕亮度和音量大小
HDU-1541 Stars 树状数组
HDU-1166 敌兵布阵 树状数组
gulp 安装步骤
css3 box-reflect 倒影效果
CSS3 六边形绘制
HTML5 <canvas> 基础学习
ngDialog 设置其宽度大小
热门文章
CSS3 滤镜
AngularJS Http
AngularJS 表格
AngularJS 过滤器
Angular JS Scope(作用域)
Fastdfs 上传图片
Spring MVC 上传文件
Centos7 上安装 FastDFS
win10上VMare安装Centos7并使用Xshell连接Centos
centos7中输入ifconfig出现ens33,没有eth0
Copyright © 2011-2022 走看看