【发布时间】:2013-04-29 14:45:37
【问题描述】:
我在主页中添加了可视化 webpart。任何人都可以为我提供 java 脚本以每 2 分钟刷新一次此 Webpart。
感谢您的宝贵时间。
问候, 桑迪
【问题讨论】:
标签: sharepoint sharepoint-2010 refresh visual-web-developer-2010
我在主页中添加了可视化 webpart。任何人都可以为我提供 java 脚本以每 2 分钟刷新一次此 Webpart。
感谢您的宝贵时间。
问候, 桑迪
【问题讨论】:
标签: sharepoint sharepoint-2010 refresh visual-web-developer-2010
我相信您无需额外的 JavaScript 即可实现这一目标。如果您在 Web 部件中构建计时(使用计时器)会怎样?然后,您可以公开允许最终用户调整刷新间隔的 Web 部件属性。如果您不需要调整刷新间隔,那么您不需要公开该属性。希望这会有所帮助。
示例 按照此link 了解如何在 Visual Web 部件中使用 ajax。然后执行以下操作
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:ListBox ID="ListBox1" runat="server" Height="177px" Width="269px"></asp:ListBox>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
</asp:UpdatePanel>
<asp:Timer ID="Timer1" runat="server" Interval="10000"
onprerender="Timer1_PreRender" ontick="Timer1_Tick">
</asp:Timer>
</div>
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
namespace vwpTestAjaxRefresh.VisualWebPart1
{
public partial class VisualWebPart1UserControl : UserControl
{
protected void Timer1_Tick(object sender, EventArgs e)
{
string currenttime = DateTime.Now.ToString("MM/dd/yy H:mm:ss zzz");
ListBox1.Items.Add("Hello World at " + currenttime);
}
}
}
希望这会有所帮助。
【讨论】: