using System;
using System.Web.UI;

namespace C1InputDateNullable
{
    public partial class _Default : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!txtToDateTime.Date.HasValue)
            {
                txtToDateTime.Date = DateTime.Now;

                var dateString = txtToDateTime.Date.Value.ToString("dd/MM/yyyy");

                string scriptCode = $"$(function() {{ $('#{txtToDateTime.ClientID}').c1inputdate('option', 'value', '{dateString}'); }});";

                ScriptManager.RegisterStartupScript(
                    this,
                    GetType(),
                    "refreshC1Date" + Guid.NewGuid(),
                    scriptCode,
                    true
                );
            }
        }
    }
}