WebMonthCalendar.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using FastReport.Dialog;
  2. using System;
  3. using System.Globalization;
  4. using System.Text;
  5. using System.Web;
  6. using System.Web.UI;
  7. using System.Web.UI.WebControls;
  8. namespace FastReport.Web
  9. {
  10. public partial class WebReport : WebControl, INamingContainer
  11. {
  12. private void MonthCalendarChange(MonthCalendarControl dp, string value)
  13. {
  14. dp.SelectionStart = DateTime.ParseExact(value, "d", CultureInfo.InvariantCulture);
  15. }
  16. private string GetMonthCalendarHtml(MonthCalendarControl control)
  17. {
  18. control.FillData();
  19. ControlFilterRefresh(control);
  20. string id = Prop.ControlID + control.Name;
  21. StringBuilder html = new StringBuilder();
  22. string selectedDate = control.SelectionStart.Month.ToString() + "/" + control.SelectionStart.Day.ToString() + "/" + control.SelectionStart.Year.ToString();
  23. string ev = GetEvent("onchange", control, string.Format("document.getElementById('{0}').value", id));
  24. html.AppendFormat("<div class=\"{0}\" style=\"{1}\" onchange=\"{2}\" id=\"{3}\"></div>",
  25. "",
  26. GetMonthCalendarStyle(control),
  27. ev,
  28. id
  29. );
  30. html.Append("<script>$(function() {$( \"#").Append(id).AppendLine("\" ).datepicker();");
  31. html.Append("$( \"#").Append(id).Append("\" ).datepicker( \"option\", \"dateFormat\", \"").
  32. Append(WebReportProperties.DEFAULT_DATE_TIME_PICKER_FORMAT).AppendLine("\" );");
  33. html.Append("$( \"#").Append(id).AppendFormat("\" ).datepicker( \"setDate\", \"{0}\", \"", selectedDate).
  34. Append(WebReportProperties.DEFAULT_DATE_TIME_PICKER_FORMAT).AppendLine("\" );");
  35. html.Append("});</script>");
  36. //control.FilterData();
  37. return html.ToString();
  38. }
  39. private string GetMonthCalendarStyle(MonthCalendarControl control)
  40. {
  41. return GetStandardStyle(control);
  42. }
  43. }
  44. }