2013-08-07 111 views
0

我有一個顯示數據庫某些細節的中繼器。我希望在數據庫中添加一個新行時,中繼器也應該動態更新。我通過在更新面板中放置中繼器並在其中放置一個定時器來完成此操作。是否有任何其他方法在js或JavaScript或任何其他方法,我想要添加一個記錄時添加一個效果(滑下,淡入淡出)就像facebook側通知欄。將記錄添加到數據庫時更新中繼器

回答

1

你可以用中繼到一個div併爲類名稱訪問它 使顯示:沒有這個div <div class="abc>" 和腳本

$(document).ready(function() { 
      $('.abc').click(function() { 
       $('.show').SlideDown('slow'); 
      }); 
     }); 
     $(document).ready(function() { 
      $(".abc").trigger('click') 
     }); 
1

在頁面加載綁定試試這個

reapeter

protected void Page_Load(object sender, EventArgs e) 
    { 
     lbl.Text = System.DateTime.Now.ToString(); 
     rptData.DataSource = YourDataSource; 
     rptData.DataBind(); 
    } 


<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always"> 
    <ContentTemplate> 
     <asp:Timer ID="Timer1" runat="server" Interval="1000"> 
     </asp:Timer> 
**timer for postback at some interval** 
**you can remove label** 
     <asp:Label Text="text" runat="server" ID="lbl" /> 
     <asp:Repeater runat="server" ID="rptData"> 
      <ItemTemplate> 
**your repeater** 
      </ItemTemplate> 
     </asp:Repeater> 
    </ContentTemplate> 
</asp:UpdatePanel> 

在計時器間隔頁面會回傳,你可以得到更新的記錄

+0

我希望在添加記錄時顯示滑下效果。我按時間順序下訂單,所以當添加新記錄時,它會被添加。 –

相關問題