My master page has text box : txt1 contentplaceholder= holder1
my content page has a textbox : txt2
when I display the content page, it has to display the client side time (not the server time) automatically without any click events. txt2.text ==> dd MMM format (eg : 31 May)
i found the following code :
<input type="hidden" id="clienttime" runat="server" />
(function $ {
$("#clienttime").val(new Date().toUTCString());
});
but, its not working and i am not sure about how to call this function and where to insert the code exactly. Please explain in step by step
All you need is
<input type="hidden" id="clienttime" runat="server" />
<script>
$("#clienttime").val(new Date().toUTCString());
</script>
BUT, this puts the time in a hidden field so it can't be seen.
If it should be seen, change the hidden input to a label or normal textbox.
<label id="lblClientTime"></label>
<script>
$("#lblClientTime").text(new Date().toUTCString());
</script>
Requires jQuery.