没有渲染页面的呼叫计时器刻度事件 [英] call timer tick event without render page

查看:130
本文介绍了没有渲染页面的呼叫计时器刻度事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

iam在asp.net4网站上工作
我有问题
我希望用户收到有关表更改的通知
含义
每次在speicif表中插入行
更新用户界面中的行数
所以我在母版页中添加标签
&我添加了计时器&我每秒钟调用一次函数,即可从该表中获取总行数
但我遇到1个问题
调用timer_tick事件时,页面将自我呈现
我Aready在母版页调用updatepanel1中有updatepanel
所以我添加了另一个updatelpanel updatepanel2

iam working on asp.net4 web site
i have issue
that i want user to be notified for table change
meaning
every time row insretd in speicif table
update no of rows in user interface
so i add label in master page
& i add timer & every helf second i call function that get the total rows from this table
but i hvae 1 problem
page is render it self when calling timer_tick event
i aready have updatepanel in master page call updatepanel1
so i add another updatelpanel updatepanel2

<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional" >
   <ContentTemplate>
   <asp:Timer ID="Timer1" Interval="250" runat="server" ontick="Timer1_Tick"/>
   </ContentTemplate>
   </asp:UpdatePanel>


但是当我打开任何页面时都无法渲染该页面,因为无法渲染页面,因为它不会为我重新加载任何内容,但是每次调用计时器事件时都会渲染该页面
所以我需要的是调用计时器控件,其中没有效果页或整个站点的部分渲染,用于冷杉行计数的标签
计时器控件在母版页中


but the page is render when i open any page i can''t edit in it becasue page is render it doesn''t dir any reload for me but it''s render with every call to the timer event
so what i need is calling timer control with out effect page or whole site partial render for label that fir rows count
timer control is in master page

推荐答案

这听起来有些荒唐,但您的UpdatePanel是否正确执行了它的工作? IE.你有一种叫部分回发的方法吗?您需要一个触发器或一段JavaScript来触发回发,即

函数doSubmit()
{
This might sound darft but is your UpdatePanel doing it''s job correctly? Ie. do you have a means of calling the partial postback? You need a trigger or a piece of javascript that will fire the postback ie.

function doSubmit()
{


get(``timervalue'').value ++;
__doPostBack(''updatepanelid'',args);
}
get(''timervalue'').value++;
__doPostBack(''updatepanelid'',args);
}


最明显的问题是:确定要在用户界面中使用它吗?

这种设计将使整个页面每秒为每个用户在服务器上运行4次.这不理想.

如果确实需要此功能,则可以使用对Web服务的AJAX调用,并使用结果来更新单个DOM元素. jQuery可以做到这一点,但需要做一些工作才能使其健壮.
The most obvious question is: are you sure you need this in your UI?

This design will cause the full page to run on the server 4 times per second for each user. This is not ideal.

If you really need this functionality, you could use an AJAX call to a web service and use the result to update a single DOM element. jQuery can do this but it will require some work to make it robust.


这篇关于没有渲染页面的呼叫计时器刻度事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆