Below example helps you to display current time on the web page. Textbox value will be updated with the current time every second.
Add following code to the page,
<script type="text/javascript">
function DisplayTime()
{
var currentDate = new Date();
document.getElementById("<%= TextTime.ClientID %>").value = currentDate.toLocaleTimeString();
window.setTimeout("DisplayTime()", 1000);
}
</script>
<script type="text/javascript">
window.setTimeout("DisplayTime()", 1000);
</script>
<asp:TextBox ID="TextTime" runat="server"></asp:TextBox>
No comments:
Post a Comment