I have a user control where I was getting the server time and doing using a AJAX timer to update it every second. This was very slow and I've been told it is better to do it on the client side.
So I came up with this...but it isn't working. Any suggestions?
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="DateTime.ascx.vb" Inherits="UserControls_WebUserControl" %>
<script type="text/javascript">
window.onload = function () {
getDate();
};
function getDate() {
var dt = new Date();
var element = document.getElementById("client_time");
element.text = dt.toDateString();
}
</script>
<form name="headerForm">
<asp:Table Width="100%" ID="formatTable" runat="server">
<asp:TableRow>
<asp:TableCell ColumnSpan="2">
<asp:Image ImageUrl="~/Logo.jpg" ID="Image1" runat="server" />
</asp:TableCell>
<asp:TableCell>
<input type="text" size="10" maxlength="10" value="" name="client_time" />
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</form>
namefield of the element, but it lacks theidneeded to find it viagetElementById. Also,.textwon't do anything, you need to set itsvalueattribute.innerHTML). As for time: quackit.com/javascript/tutorial/javascript_date_and_time.cfm