ASP timer Control is refreshing the whole page?

2019-03-02 18:05发布

I have a ASP timer control which is supposed to run every three minutes. Although I kept the Timer control in an update panel, it is refreshing the whole page every time it runs.

Is there any it only refresh the particular section of the page, not the whole page?

<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>

4条回答
何必那么认真
2楼-- · 2019-03-02 18:21
 <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> 
查看更多
走好不送
3楼-- · 2019-03-02 18:30

you need to use UpdatePanel Triggers. Conditional Update Panels with triggers, and msdn source. 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> 
查看更多
倾城 Initia
4楼-- · 2019-03-02 18:36

        <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>     
查看更多
Deceive 欺骗
5楼-- · 2019-03-02 18:39

Use update panel and add all the control's inside update panel which you don't want to be refreshed or postback by any event

查看更多
登录 后发表回答