Text properties C1DateInput to C1InputDate 2025v2 399

Posted by: enrique.pv-ext on 12 May 2026, 2:52 am EST

  • Posted 12 May 2026, 2:52 am EST - Updated 12 May 2026, 2:58 am EST

    Hi,

    Migrate from 2010v1 to 2025v2 399 in ASP.NET WebForms NET Framework 4.8.1.

    Using C1InputDate from C1.Web.Wijmo.Controls.48.dll

    Changes C1DateInput to C1InputDate control.

    Now those properties not appears: Text

    My legacy code:

       #region set date format parameter
       DateTime d1 = new DateTime();
       DateTime d2 = new DateTime();
    
       if (Text1.Text.Length == 4)
       {
           d1 = Convert.ToDateTime("01/01/" + Text1.Text);
           desde = d1.ToShortDateString();
       }
       else
       {
           d1 = Convert.ToDateTime(Text1.Text);
           desde = C1CalDesde.SelectedDate.ToShortDateString();
       }
       d2 = DateTime.Now;
    
       fecha = desde.Split('/');

    any suggestions ?

    Full code LEGACY:

        #region set date format parameter
        DateTime d1 = new DateTime();
        DateTime d2 = new DateTime();
    
        var value = Text1.Date;
    
        if (Text1.Text.Length == 4)
        {
            d1 = Convert.ToDateTime("01/01/" + Text1.Text);
            desde = d1.ToShortDateString();
        }
        else
        {
            d1 = Convert.ToDateTime(Text1.Text);
            desde = C1CalDesde.SelectedDate.ToShortDateString();
        }
        d2 = DateTime.Now;
    
        fecha = desde.Split('/');
    
        day = fecha[0];
        month = fecha[1];
        year = fecha[2].Substring(0, 4);
    
        desde = year + "/" + month + "/" + day + " 00:00";
        dateA = day + "/" + month + "/" + year + " 00:00";
    
        switch (txtTreeCols.Value)
        {
            case "TS1":
                #region hourly
                if (d1.ToShortDateString() == d2.ToShortDateString())
                {
                    hasta = year + "/" + month + "/" + day + " " + String.Format("{0:00}", d2.Hour) + ":" + String.Format("{0:00}", d2.Minute) + ":" + d2.Second;
                    queryDateHasta = day + "/" + month + "/" + year + " " + String.Format("{0:00}", d2.Hour) + ":" + String.Format("{0:00}", d2.Minute) + ":" + d2.Second;
                    dateB = day + "/" + month + "/" + year + " " + String.Format("{0:00}", d2.Hour) + ":" + String.Format("{0:00}", d2.Minute) + ":" + d2.Second;
                    dateNow = DateTime.Now.ToShortDateString();
                }
                else
                {
                    hasta = year + "/" + month + "/" + day + " 23:59";
                    queryDateHasta = day + "/" + month + "/" + year + " 23:59";
                    dateB = day + "/" + month + "/" + year + " 23:59";
                    dateNow = DateTime.Now.ToShortDateString();
                }
                break;
            #endregion
            case "TS2":
                #region monthly
                if ((d1.Month == d2.Month) && (d1.Year == d2.Year))
                {
                    hasta = year + "/" + month + "/" + String.Format("{0:00}", d2.Day) + " " + String.Format("{0:00}", d2.Hour) + ":" + String.Format("{0:00}", d2.Minute) + ":" + String.Format("{0:00}", d2.Second);
                    queryDateHasta = month + "/" + year + " " + String.Format("{0:00}", d2.Hour) + ":" + String.Format("{0:00}", d2.Minute) + ":" + d2.Second;
                    dateB = String.Format("{0:00}", d2.Day) + "/" + month + "/" + year + " " + String.Format("{0:00}", d2.Hour) + ":" + String.Format("{0:00}", d2.Minute) + ":" + d2.Second;
                }
                else
                {
                    desde = year + "/" + month + "/" + "01" + " 00:00:00";
                    hasta = d2.Year + "/" + month + "/" + getMonthDays((int.Parse(month) - 1), int.Parse(year)).ToString() + " 23:59";
                    queryDateHasta = month + "/" + year + " 23:59";
                    dateB = getMonthDays((int.Parse(month) - 1), int.Parse(year)).ToString() + "/" + month + "/" + year + " 23:59";
                }
                break;
            #endregion
            default:
                #region annually
                if (d1.Year == DateTime.Now.Year)
                {
                    desde = year + "/01/01 00:00:00";
                    hasta = year + "/" + String.Format("{0:00}", d2.Month) + "/" + String.Format("{0:00}", d2.Day) + " " + String.Format("{0:00}", d2.Hour) + ":" + String.Format("{0:00}", d2.Minute) + ":" + String.Format("{0:00}", d2.Second);
                    dateB = String.Format("{0:00}", d2.Day) + "/" + String.Format("{0:00}", d2.Month) + "/" + year + " " + String.Format("{0:00}", d2.Hour) + ":" + String.Format("{0:00}", d2.Minute) + ":" + String.Format("{0:00}", d2.Second);
                }
                else
                {
                    desde = year + "/01/01 00:00:00";
                    hasta = d1.Year + "/12/31 23:59";
                    dateB = "31/12/" + year + " 23:59";
                }
                #endregion
                break;
        }
        #endregion
    
  • Posted 12 May 2026, 5:43 am EST

    Hello Enrique,

    To retrieve the text value from ‘C1InputDate’, you can use the client-side ‘getText()’ method. Please refer to the following documentation for more details:

    https://help.grapecity.com/wijmo/3/webframe.html#Wijmo~wijmo.input.wijinputdate~getText.html

    Please let us know if you encounter any issues while using it.

    Regards,

    Uttkarsh

  • Posted 12 May 2026, 5:53 am EST

    Hello Enrique,

    And for ServerSide, you can use Date property. Please refer to the attached sample for implementation. (see C1InputDate_Sample.zip)

    Regards,

    Uttkarsh.

  • Posted 14 May 2026, 6:37 am EST

    Text1 is C1DateInput (legacy) with property Text

        if (Text1.Text.Length == 4)
        {
            d1 = Convert.ToDateTime("01/01/" + Text1.Text);
            desde = d1.ToShortDateString();
        }
        else
        {
            d1 = Convert.ToDateTime(Text1.Text);
            desde = C1CalDesde.SelectedDate.ToShortDateString();
        }
        d2 = DateTime.Now;

    I want can manage date as

    hourly

    monthly

    annually

  • Posted 15 May 2026, 1:07 am EST

    Hello Enrique,

    It is easier to manage Date object instead of processing Text. To give you an example, your code using Date property will be equivalent to the following:

    #region set date format parameter
    DateTime d1 = new DateTime();
    DateTime d2 = DateTime.Now;
    
    // Use Date property instead of Text
    if (Text1.Date.HasValue)
    {
        d1 = Text1.Date.Value;
    }
    else
    {
        // Fallback: if only a year was typed (4 chars), Date may be null
        d1 = new DateTime(DateTime.Now.Year, 1, 1);
    }
    
    string year  = d1.Year.ToString();
    string month = d1.Month.ToString("00");
    string day   = d1.Day.ToString("00");
    
    desde  = year + "/" + month + "/" + day + " 00:00";
    dateA  = day + "/" + month + "/" + year + " 00:00";
    
    switch (txtTreeCols.Value)
    {
        case "TS1":
            #region hourly
            if (d1.Date == d2.Date)
            {
                hasta          = $"{year}/{month}/{day} {d2.Hour:00}:{d2.Minute:00}:{d2.Second:00}";
                queryDateHasta = $"{day}/{month}/{year} {d2.Hour:00}:{d2.Minute:00}:{d2.Second:00}";
                dateB          = queryDateHasta;
            }
            else
            {
                hasta          = $"{year}/{month}/{day} 23:59";
                queryDateHasta = $"{day}/{month}/{year} 23:59";
                dateB          = queryDateHasta;
            }
            dateNow = d2.ToShortDateString();
            break;
            #endregion
    
        case "TS2":
            #region monthly
            if (d1.Month == d2.Month && d1.Year == d2.Year)
            {
                hasta          = $"{year}/{month}/{d2.Day:00} {d2.Hour:00}:{d2.Minute:00}:{d2.Second:00}";
                queryDateHasta = $"{month}/{year} {d2.Hour:00}:{d2.Minute:00}:{d2.Second:00}";
                dateB          = $"{d2.Day:00}/{month}/{year} {d2.Hour:00}:{d2.Minute:00}:{d2.Second:00}";
            }
            else
            {
                int lastDay = getMonthDays(d1.Month - 1, d1.Year);
                desde        = $"{year}/{month}/01 00:00:00";
                hasta        = $"{year}/{month}/{lastDay:00} 23:59";
                queryDateHasta = $"{month}/{year} 23:59";
                dateB        = $"{lastDay:00}/{month}/{year} 23:59";
            }
            break;
            #endregion
    
        default:
            #region annually
            if (d1.Year == d2.Year)
            {
                desde = $"{year}/01/01 00:00:00";
                hasta = $"{year}/{d2.Month:00}/{d2.Day:00} {d2.Hour:00}:{d2.Minute:00}:{d2.Second:00}";
                dateB = $"{d2.Day:00}/{d2.Month:00}/{year} {d2.Hour:00}:{d2.Minute:00}:{d2.Second:00}";
            }
            else
            {
                desde = $"{year}/01/01 00:00:00";
                hasta = $"{year}/12/31 23:59";
                dateB = $"31/12/{year} 23:59";
            }
            break;
            #endregion
    }
    #endregion

    Please note that we have not tested the code as we do not have complete info on your implementation. So, please test it thoroughly.

    The key changes are:

    • Text1.Date (a DateTime?) replaces Text1.Text, so there’s no need to parse strings or check for a 4-character year entry — the control gives you a proper DateTime object directly.

    • d1.Date == d2.Date replaces d1.ToShortDateString() == d2.ToShortDateString() for the same-day comparison — cleaner and culture-independent.

    • String interpolation with format specifiers ({d2.Hour:00}) replaces the verbose String.Format(“{0:00}”, …) calls throughout.

    • getMonthDays is called with d1.Month - 1 and d1.Year directly from the Date property, avoiding the intermediate string parsing.

    If you encounter any issues or if this approach does not meet your use case requirements, please share complete details of your implementation so that we can provide the best possible solution. It would also be helpful if you could provide a stripped-down sample or update the sample shared in our previous response.

    Regards,

    Uttkarsh.

  • Posted 15 May 2026, 1:41 am EST

    Hello Enrique,

    Please find the sample attached we used to implement your legacy code logic with newer version: C1InputDate_Sample_Mod.zip

    Regards,

    Uttkarsh.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels