无论条件如何,ASP计时器都会在每个时间间隔内更新Updatepanel

时间:2015-02-03 19:34:42

标签: asp.net ajax vb.net timer updatepanel

无论Timer1_Tick内部的条件如何,

UpdatePanel1每3秒更新一次。如果x = 1,我只想更新。 进一步解释: 如果我完全删除了UpdatePanel1.Update()行以及Timer1_Tick()中的所有内容,那么UpdatePanel1仍会每3秒更新一次。问题不在于声明整数x的位置。我希望问题出在ASP代码中。

<asp:ScriptManager runat="server" id="ScriptManager1" />
<div><asp:Timer runat="server" id="Timer1" Interval="3000" OnTick="Timer1_Tick" /></div>
<asp:UpdatePanel runat="server" id="UpdatePanel1" UpdateMode="Conditional" RenderMode="Block">
 <Triggers><asp:AsyncPostBackTrigger ControlID="Timer1" /></Triggers>
 <ContentTemplate>
  <asp:Label id="Label1" runat="server"></asp:Label>
 </ContentTemplate>
</asp:UpdatePanel>

和vb代码..

Sub Timer1_Tick(ByVal sender As Object, ByVal e As EventArgs)
 'If x=1 Then
  'UpdatePanel1.Update() 'Update only if x=1
 'Else 
 'Do nothing
 'End If
 'Regardless of what is in this subfunction, nothing or the above, Updatepanel updates every 3 seconds
End Sub

2月4日:UpdatePanel1仍然无条件地每3秒更新/重新加载一次。问题在于我认为的ASP代码。欢迎提出答案或想法。

0 个答案:

没有答案