以特定间隔刷新更新面板

时间:2011-02-09 14:40:29

标签: asp.net vb.net

如何在一段时间后触发我的更新面板刷新。

3 个答案:

答案 0 :(得分:4)

您可以使用ASP.NET AJAX Timer控件在一段时间后触发事件。 从ASP.NET官方网站查看此视频,了解如何使用Timer: http://www.asp.net/ajax/videos/how-do-i-use-the-aspnet-ajax-timer-control

答案 1 :(得分:2)

使用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的链接不再有效,请使用this MSDN article

答案 2 :(得分:1)

  1. 向页面添加隐藏按钮
  2. 使用CSS隐藏按钮
  3. 将按钮设置为UpdatePanel的触发器
  4. 使用Javascript设置计时器以“点击”按钮。
  5. 使用ID“btnRefresh”为页面添加一个按钮。

    将按钮设置为更新面板上的触发器。

    添加以下Javascript:

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

    setTimeout函数将每10秒调用一次RefreshUpdatePanel()函数。 RefreshUpdatePanel