アプリケーションには、日付と時刻を表示する必要があります。これを行うために、.netアプリケーションでAjaxを使用しています。
現在私はこのコードを持っています
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:Timer ID="UpdateTimer" runat="server" Interval="1000" OnTick="UpdateTimer_Tick" />
<asp:UpdatePanel ID="TimedPanel" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="UpdateTimer" EventName="Tick" />
</Triggers>
<ContentTemplate>
<asp:Label runat="server" ID="DateStampLabel" />
</ContentTemplate>
</asp:UpdatePanel>
ページを更新するときの1秒の遅延を除けば、問題なく機能しています。私の質問はこれです、これはこれを達成するための最良の方法ですか?私はおそらく秒を表示しないことで逃げることができます...それはそれほど重要ではないかもしれません。私がそれをするなら、私はそれをどのようにすべきですか?
これがコードビハインドです...
Protected Sub UpdateTimer_Tick(ByVal sender As Object, ByVal e As System.EventArgs)
DateStampLabel.Text = DateTime.Now.ToString()
End Sub
ありがとう!