乱的微软框,你可以使用一个UpdatePanel and a Timer。
如果你不喜欢微软盒子的内容,并想使用jQuery/JavaScript,你可以定期发送AJAX请求(使用window.setInterval
方法)到ASP.NET PageMethod(在这种情况下,基本上你必须给自己有点痛苦地阅读jQuery的documentation/tutorials并写一点代码)。
因此,一个ASP.NET PageMethod的:
[WebMethod]
public static int Approved()
{
return (from obj in db.RequestList
where obj.IsApproved == "Approved"
select obj).Count();
}
,然后每分钟左右锤这PageMethod的用AJAX请求:
window.setInterval(function() {
$.ajax({
url: '/foo.aspx/Approved',
type: 'POST',
contentType: 'application/json',
data: '{ }',
success: function(result) {
var count = result.d;
// TODO: do something with the count returned by the server
// like assigning it to a label or something:
$('#someLabelId').html(count);
}
});
}, 60 * 1000);
如果你想要的网页在没有回传的情况下更新,你需要使用ajax和web服务(例如jQuery ajax()方法和ASP.NET WCF服务) – Zachary 2012-04-16 22:01:22
你知道如何使用jQuery吗? – 2012-04-16 22:02:05
你有没有任何示例代码或链接我可以学习吗? – Hoorayo 2012-04-16 22:02:32