2011-02-09 62 views

回答

1
  1. 添加一个隐藏按钮,您的网页
  2. 隐藏与CSS
  3. 设置按钮充当触发UpdatePanel的
  4. 使用Javascript设置一个计时器按钮“点击”的按钮。

将一个按钮添加到ID为“btnRefresh”的页面。

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

添加以下JavaScript:

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

setTimeout('RefreshUpdatePanel()', 10000); 

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

+0

谢谢,如果我wawsnt使用AJAX这将是一个伟大的方法 – MyHeadHurts 2011-02-09 14:51:25

+0

然后,它听起来像定时器控制将是你最好的选择。 – 2011-02-09 14:52:58

2

使用一个ASP.Net Ajax的定时器触发的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