How to set Today’s Date by TimeZone to Ajax CalenderExtender

Code in .aspx:

<html xmlns=""&gt;
<head id="Head1" runat="server">
<script type="text/javascript">
function clientShowing(sender, args) {
if (new Date($get("HiddenField1").value) != null) {
sender.set_todaysDate(new Date($get("HiddenField1").value));
<form id="form2" runat="server">
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:calendarextender ID="CalendarExtender1" runat="server" Enabled="True" Format="dd/MM/yyyy"
TargetControlID="TextBox1" OnClientShowing="clientShowing"
<asp:HiddenField ID="HiddenField1" runat="server" />


Code in .aspx.cs:

           using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)
        HiddenField1.Value =
TimeZoneInfo.FindSystemTimeZoneById("Tonga Standard Time"))).ToString();

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s