为什么 JQuery 函数在更新面板时不起作用?请看下面的代码。
<asp:Timer ID="Schedule_Timer" runat="server" Interval="10000"></asp:Timer>
<asp:UpdatePanel ID="Schedule_UpdatePanel" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Schedule_Timer" EventName="Tick" />
</Triggers>
<ContentTemplate>
<asp:Panel ID="Schedule_Panel" runat="server" Height="250px" Width="250px">
<asp:Literal ID="Schedule_Label" runat="server" Text=""></asp:Literal>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
<script>
$('#test').cycle({
fx: 'scrollUp',
timeout: 6000,
delay: -2000
});
</script>
通过Schedule_Label
代码隐藏填写:
Protected Sub Schedule_Timer_Tick(sender As Object, e As System.EventArgs) Handles Schedule_Timer.Tick
PrintTheSchedule()
End Sub
Private Sub PrintTheSchedule()
//This is just for example, the actual data is taken from gridview based on the realtime
Schedule_Label.Text = "<div id='test'>" & _
"<div>test 1</div>" & _
"<div>test 2</div>" & _
"<div>test 3</div>" & _
"<div>"
End Sub
在前 10 秒,JQuery 循环test
div。但是在 UpdatePanel 刷新后,JQuery 不再运行,导致所有test
div 值都显示在页面上。如何解决这个问题?非常感谢。