ASP计时器控件正在刷新整个页面吗?

问题描述 投票:1回答:4

我有一个ASP计时器控件,该控件应该每三分钟运行一次。尽管我将Timer控件保留在更新面板中,但它每次运行时都会刷新整个页面。

是否仅刷新页面的特定部分,而不刷新整个页面?

<div>
        <asp:UpdatePanel ID="UpdatePanel4" runat="server">
            <ContentTemplate>
                <asp:Timer ID="Timer1" runat="server" ontick="Timer1_Tick" Interval="300000" >
                </asp:Timer>
            </ContentTemplate>
        </asp:UpdatePanel>               
    </div>
asp.net asp.net-ajax webforms
4个回答
2
投票

        <asp:Timer runat="server" id="UpdateTimer" interval="200" ontick="function" />

        <asp:UpdatePanel runat="server" id="TimedPanel" updatemode="Conditional">

            <Triggers>
                <asp:AsyncPostBackTrigger controlid="UpdateTimer" eventname="Tick" />
            </Triggers>

            <ContentTemplate>
                <asp:Label runat="server" id="label1" />
                <asp:TextBox ID="textbox1" runat="server"></asp:TextBox>
            </ContentTemplate>

        </asp:UpdatePanel>     

2
投票
<asp:UpdatePanel ID="UpdatePanel4" runat="server">
  <Triggers>
    <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
  </Triggers>
  <ContentTemplate>
    <asp:Timer ID="Timer1" runat="server" ontick="Timer1_Tick" Interval="300000">
    </asp:Timer>
  </ContentTemplate>
</asp:UpdatePanel> 

1
投票

您需要使用UpdatePanel触发器。 Conditional Update Panels with triggers和msdn源。 Updatepanel with Triggers

   <asp:UpdatePanel ID="UpdatePanel4" runat="server">
       <ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
    </Triggers>
<asp:Timer ID="Timer1" runat="server" ontick="Timer1_Tick" Interval="300000"> </asp:Timer>
                </ContentTemplate>
            </asp:UpdatePanel> 

0
投票

使用更新面板并添加您不希望因任何事件刷新或回发的控件内部所有更新面板

© www.soinside.com 2019 - 2024. All rights reserved.