簡體   English   中英

以特定間隔刷新更新面板

[英]refresh update panel at certain interval

如何在一段時間后觸發我的更新面板刷新。

您可以使用ASP.NET AJAX Timer控件在一段時間后觸發事件。 從ASP.NET官方網站查看此視頻,了解如何使用Timer: http//www.asp.net/ajax/videos/how-do-i-use-the-aspnet-ajax-timer-control

使用ASP.Net-Ajax Timer來觸發UpdatePanel:

<asp:UpdatePanel runat="server" UpdateMode="Conditional">
    <ContentTemplate>
        <%--Typical GridView--%>
        <asp:GridView 
            ID="gvOperations" runat="server" 
            GridLines="None" Width="100%"
            AllowSorting="true" DataSourceID="odsOperations"
            OnRowDataBound="GvOperations_RowDataBound">
            <AlternatingRowStyle BackColor="aliceBlue" />
            <HeaderStyle HorizontalAlign="Left" />
        </asp:GridView>
        <%--The Timer that causes the partial postback--%>
        <asp:Timer runat="server" Interval="1500" OnTick="Timer_Tick" />                
    </ContentTemplate>
</asp:UpdatePanel>  

http://mattberseth.com/blog/2007/08/using_the_ajax_timer_control_a.html

更新 :由於Matt的鏈接不再起作用,請使用此MSDN文章

  1. 在頁面中添加隱藏按鈕
  2. 使用CSS隱藏按鈕
  3. 將按鈕設置為UpdatePanel的觸發器
  4. 使用Javascript設置計時器以“單擊”按鈕。

使用ID“btnRefresh”向頁面添加一個按鈕。

將按鈕設置為更新面板上的觸發器。

添加以下Javascript:

function RefreshUpdatePanel() {
    __doPostBack('<%= btnRefresh.ClientID %>','');  
}

setTimeout('RefreshUpdatePanel()', 10000);

setTimeout函數將每10秒調用一次RefreshUpdatePanel()函數。 RefreshUpdatePanel

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM