gpt4 book ai didi

c# - ASP.NET使用C#,在Repeater中自动刷新div

转载 作者:行者123 更新时间:2023-11-28 10:10:39 25 4
gpt4 key购买 nike

我使用 Repeater 控件来列出线程。

还有一个带有标签控件的 Div,用于在 Repeater ItemTemplate 中显示发布日期。

这就是我现在正在做的事情,但它不是独立自动刷新特定的 div 。它会自动刷新整个页面。

setInterval(function () { $(".refresh").load(location.href + " .refresh"); }, 5000);


<asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="Repeater1_ItemDataBound">
<HeaderTemplate>

</HeaderTemplate>
<ItemTemplate>
..........
.............

<div class="date"><asp:Label ID="post_date_LB" runat="server"></asp:Label></div>
//display the posted date for each thread, And I want it to auto refresh independently not the whole page.

...............
...................

</ItemTemplate>
<FooterTemplate>

</FooterTemplate>
</asp:Repeater>

我希望发布日期显示如下:10 分钟前发布、一小时前发布等。

所以我需要一个自动刷新div。

有什么想法如何让我的中继器中的div可以独立自动刷新吗?

如果使用js或jquery,我认为可能存在DIV重复id的问题。

希望有一个解决方案。

提前致谢! :)

最佳答案

您可以使用 AJAX。

您可以将需要刷新的部分单独放在UpdatePanel控件中。您还需要使用一个脚本管理器控件。

它在您的 AJAX 工具箱中。

关于c# - ASP.NET使用C#,在Repeater中自动刷新div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7465168/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com