开发者

refresh update panel at certain interval

How can i trigger my u开发者_StackOverflow中文版pdate panel to refresh after a certain period of time.


You can use ASP.NET AJAX Timer control in order to fire an event after a certain period of time. Checkout this video from ASP.NET official website to find out how to use Timer: http://www.asp.net/ajax/videos/how-do-i-use-the-aspnet-ajax-timer-control


Use an ASP.Net-Ajax Timer to trigger the 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

Update: Since Matt's link doesn't work anymore, use this MSDN article.


  1. Add a hidden button to your page
  2. Hide the button with CSS
  3. Set the button to act as a trigger for the UpdatePanel
  4. Set a timer using Javascript to "click" the button.

Add a button to your page with the ID "btnRefresh".

Set the button to act as a trigger on the Update Panel.

Add the following Javascript:

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

setTimeout('RefreshUpdatePanel()', 10000);

The setTimeout function will call the RefreshUpdatePanel() function every 10 seconds. The RefreshUpdatePanel

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜