To get system datetime you can call PageMethod from javascript.
Follow the steps :
1. Add script manager to .aspx and set EnablePageMethods to true:
<asp:ScriptManager runat="server" EnablePageMethods="true">
2. Add using statement for System.Web.Services namespace in code behind :
using System.Web.Services;
3. Add WebMethod to code behind to get system datetime :
[WebMethod]
public static string GetSystemDateTime()
{
return DateTime.Now.ToString();
}
4. Now call WebMethod from javascript function and bind return value to the textbox :
<script type="text/javascript">
function ShowDate() {
PageMethods.GetSystemDateTime(function (result) {
document.getElementById("TextBoxID").value = result;
});
}
</script>
Please don't forget to mark as answer if it helps you.