2011-02-01 105 views
0

在客戶方頁面加載()函數IM試圖讓多視點活動指數和回發到我的updatepanel1 5秒後只有活躍指數是2刷新MuliView的觀點,每5秒

下面的代碼:

<script type="text/javascript" language="JavaScript"> 
    function pageLoad() { 
     if (document.getElementById('MultiViewManage').getAttribute("ActiveViewIndex") == 2) { 
      window.setTimeout("__doPostBack('UpdatePanel1','')",5000); 
     } 
    } 
</script> 

即時通知null或者某種錯誤我做錯了什麼? 謝謝

+0

您無法訪問客戶端上的MultiView,因爲它呈現爲簡單的div。所以你也無法訪問屬性(什麼會是btw。一個可怕的地方來存儲這樣的屬性)來獲取ActiveViewIndex。 如果可能,您應該在服務器上執行此操作。 – 2011-02-01 15:30:09

回答

1

要在5秒後自動刷新更新面板(如果用戶位於MultiView的ActiveViewIndex=2上),請在UpdatePanel中使用一個ASP.Net Timer,每隔5秒觸發一次異步回發。我將嵌入應該在單獨的UpdatePanel中刷新的視圖的內容。

<asp:Timer ID="Timer1" OnTick="Timer1_Tick" runat="server" Interval="5000"></asp:Timer> 
<asp:UpdatePanel ID="UpdPanelRefresh" UpdateMode="Conditional" runat="server"> 
      <Triggers> 
       <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" /> 
      </Triggers> 
      <ContentTemplate> 
..... 

然後刷新代碼隱藏你的UpdatePanel在Timer_Tick事件處理程序的內容。

我會在外部UpdatePanel旁邊的單獨UpdatePanel中嵌入所有視圖。如果切換視圖,則必須觸發外部UpdatePanel。但計時器滴答聲將觸發屬於使用ActiveViewIndex查看的內部UpdatePanel 2