protected override void ProcessCore(TagHelperContext context, TagHelperOutput output) { if (DayName == null && MonthName == null && YearName == null) { output.SuppressOutput(); return; } output.TagName = "div"; output.TagMode = TagMode.StartTagAndEndTag; output.AppendCssClass("row xs-gutters"); var selectClass = "date-part noskin remember form-control"; if (ControlSize != ControlSize.Medium) { selectClass += " form-control-" + (ControlSize == ControlSize.Small ? "sm" : "lg"); } if (DayName.HasValue()) { var daysCol = new TagBuilder("div"); daysCol.AddCssClass("col"); var daySelect = new TagBuilder("select"); daySelect.Attributes.AddRange(new Dictionary <string, string> { { "data-native-menu", "false" }, { "name", DayName }, { "id", DayName }, { "class", selectClass }, { "data-minimum-results-for-search", "100" } }); if (Disabled) { daySelect.Attributes.Add("disabled", "disabled"); } using var _ = StringBuilderPool.Instance.Get(out var days); // Add initial option. days.AppendFormat("<option value=''>{0}</option>", _localizationService.GetResource("Common.Day")); // Add options for days. for (int i = 1; i <= 31; i++) { days.AppendFormat("<option value='{0}'{1}>{0}</option>", i, (Day != null && (Convert.ToInt32(Day) == i)) ? " selected=\"selected\"" : null); } daySelect.InnerHtml.AppendHtml(days.ToString()); daysCol.InnerHtml.AppendHtml(daySelect); output.Content.AppendHtml(daysCol); } if (MonthName.HasValue()) { var monthsCol = new TagBuilder("div"); monthsCol.AddCssClass("col"); var monthSelect = new TagBuilder("select"); monthSelect.Attributes.AddRange(new Dictionary <string, string> { { "data-native-menu", "false" }, { "name", MonthName }, { "id", MonthName }, { "class", selectClass }, { "data-minimum-results-for-search", "100" } }); if (Disabled) { monthSelect.Attributes.Add("disabled", "disabled"); } using var __ = StringBuilderPool.Instance.Get(out var months); // Add initial option. months.AppendFormat("<option value=''>{0}</option>", _localizationService.GetResource("Common.Month")); // Add options for months. for (int i = 1; i <= 12; i++) { months.AppendFormat("<option value='{0}'{1}>{2}</option>", i, (Month != null && Convert.ToInt32(Month) == i) ? " selected=\"selected\"" : null, CultureInfo.CurrentUICulture.DateTimeFormat.GetMonthName(i)); } monthSelect.InnerHtml.AppendHtml(months.ToString()); monthsCol.InnerHtml.AppendHtml(monthSelect); output.Content.AppendHtml(monthsCol); } if (YearName.HasValue()) { var yearsCol = new TagBuilder("div"); yearsCol.AddCssClass("col"); var yearSelect = new TagBuilder("select"); yearSelect.Attributes.AddRange(new Dictionary <string, string> { { "data-native-menu", "false" }, { "name", YearName }, { "id", YearName }, { "class", selectClass }, //{ "data-minimum-results-for-search", "100" } }); if (Disabled) { yearSelect.Attributes.Add("disabled", "disabled"); } using var ___ = StringBuilderPool.Instance.Get(out var years); years.AppendFormat("<option value=''>{0}</option>", _localizationService.GetResource("Common.Year")); // Add options for year. if (BeginYear == null) { BeginYear = DateTime.UtcNow.Year - 90; } if (EndYear == null) { EndYear = DateTime.UtcNow.Year + 10; } for (int i = BeginYear.Value; i <= EndYear.Value; i++) { years.AppendFormat("<option value='{0}'{1}>{0}</option>", i, (Year != null && Convert.ToInt32(Year) == i) ? " selected=\"selected\"" : null); } yearSelect.InnerHtml.AppendHtml(years.ToString()); yearsCol.InnerHtml.AppendHtml(yearSelect); output.Content.AppendHtml(yearsCol); } }