using FastReport.Dialog; using System; using System.ComponentModel; using System.Globalization; using System.Text; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace FastReport.Web { public partial class WebReport : WebControl, INamingContainer { /// /// Gets or sets date time format in jqueryui datepicker style /// [DefaultValue(WebReportProperties.DEFAULT_DATE_TIME_PICKER_FORMAT)] [Category("Data")] [Browsable(true)] public string DateTimePickerFormat { get { return Prop.DateTimePickerFormat; } set { Prop.DateTimePickerFormat = value; } } private void DateTimePickerChange(DateTimePickerControl dp, string value) { dp.Value = DateTime.ParseExact(value, "d", CultureInfo.InvariantCulture); } private string GetDateTimePickerHtml(DateTimePickerControl control) { control.FillData(); ControlFilterRefresh(control); string id = Prop.ControlID + control.Name; StringBuilder html = new StringBuilder(); if(DateTimePickerFormat == null || DateTimePickerFormat == "" || DateTimePickerFormat == WebReportProperties.DEFAULT_DATE_TIME_PICKER_FORMAT) { string s = control.Value.Month.ToString() + "/" + control.Value.Day.ToString() + "/" + control.Value.Year.ToString(); string ev = GetEvent("onchange", control, string.Format("document.getElementById('{0}').value", id)); html.AppendFormat("", "", GetDateTimePickerStyle(control), ev, id, s, control.Enabled ? "" : "disabled" ); html.Append(""); } else { string value = "(function(){{ var tStr = function(k){{ if( k < 10) return '0' + k; return k; }}; var dateTime=$('#{0}').datepicker('getDate'); if(dateTime) return tStr(dateTime.getMonth() + 1 ) + '/' + tStr(dateTime.getDate()) + '/' + tStr(dateTime.getFullYear()); return '01/01/2019';}})()"; string ev = GetEvent("onchange", control, string.Format(value, id)); html.AppendFormat("", "", GetDateTimePickerStyle(control), ev, id ); html.Append(""); } //control.FilterData(); return html.ToString(); } private string GetDateTimePickerStyle(DateTimePickerControl control) { return GetStandardStyle(control); } } }