有什么方法可以在不重新加载整个页面的情况下自动更新 Void 和 PlaceHolder 吗?
Is there any way to auto-update a Void and PlaceHolder without reloading the whole page?
我想知道是否有任何方法可以使用某些 SQL 查询自动更新 Void/PlaceHolder 而无需刷新整个 ASP 页面?
我试过一些 ASP 计时器但没有成功。
解决方案:
我已经尝试了更多 asp:updatapanel
并找到了适合我的情况的解决方案。
ASP:
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" ViewStateMode="Enabled">
<ContentTemplate>
//Content here
<asp:PlaceHolder ID = "MachineBoxHolder" runat="server" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
</asp:UpdatePanel>
<asp:Timer ID="Timer1" runat="server" Interval="2000" OnTick="Timer1_Tick">
</asp:Timer>
C#
protected void Timer1_Tick(object sender, EventArgs e)
{
//content
}
解法:
我通过这种方式找到了解决方案。
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" ViewStateMode="Enabled">
<ContentTemplate>
//Content here
<asp:PlaceHolder ID = "MachineBoxHolder" runat="server" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
</asp:UpdatePanel>
<asp:Timer ID="Timer1" runat="server" Interval="2000" OnTick="Timer1_Tick">
</asp:Timer>
C
protected void Timer1_Tick(object sender, EventArgs e)
{
//content
}
我想知道是否有任何方法可以使用某些 SQL 查询自动更新 Void/PlaceHolder 而无需刷新整个 ASP 页面?
我试过一些 ASP 计时器但没有成功。
解决方案:
我已经尝试了更多 asp:updatapanel
并找到了适合我的情况的解决方案。
ASP:
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" ViewStateMode="Enabled">
<ContentTemplate>
//Content here
<asp:PlaceHolder ID = "MachineBoxHolder" runat="server" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
</asp:UpdatePanel>
<asp:Timer ID="Timer1" runat="server" Interval="2000" OnTick="Timer1_Tick">
</asp:Timer>
C#
protected void Timer1_Tick(object sender, EventArgs e)
{
//content
}
解法:
我通过这种方式找到了解决方案。
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" ViewStateMode="Enabled">
<ContentTemplate>
//Content here
<asp:PlaceHolder ID = "MachineBoxHolder" runat="server" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
</asp:UpdatePanel>
<asp:Timer ID="Timer1" runat="server" Interval="2000" OnTick="Timer1_Tick">
</asp:Timer>
C
protected void Timer1_Tick(object sender, EventArgs e)
{
//content
}