November Happy Hour will be moved to Thursday December 5th.
AI OnAI Off
November Happy Hour will be moved to Thursday December 5th.
I have just found the answer, the PropertyCriteria needs to have the Required property set to true for each criteria:
PropertyCriteria dateCriteriaMin = new PropertyCriteria();
dateCriteriaMin.Condition = EPiServer.Filters.CompareCondition.GreaterThan;
dateCriteriaMin.Name = PAGE_DATE_PROPERTY;
dateCriteriaMin.Type = PropertyDataType.Date;
dateCriteriaMin.Value = minDate.ToString();
dateCriteriaMin.Required = true;
I am creating a page where the user can choose to view only pages published within a particular month, so I tried using the following code. But it always returns all of the pages. If I use just one of the PropertyCriteria, say dateCriteriaEnd, then this correctly returns only pages published before the end date. I could add a PropertyCriteria for selecting pages containing particular text; so FindPagesWithCriteria works with two criteria. Is this a bug FindPagesWithCriteriaor have I done missed something?
// -- Code start in EPiServer.UserControlBase
int month = 8;
int year = 2009;
DateTime minDate = new DateTime(year, month, 1, 0, 0, 1);
DateTime maxDate = new DateTime(year, month, 30, 23, 59, 59);
PropertyCriteriaCollection searchCriteria = new PropertyCriteriaCollection();
PropertyCriteria dateCriteriaEnd = new PropertyCriteria();
dateCriteriaEnd.Condition = EPiServer.Filters.CompareCondition.LessThan;
dateCriteriaEnd.Name = PAGE_DATE_PROPERTY; // PAGE_DATE_PROPERTY = "PageStartPublish";
dateCriteriaEnd.Type = PropertyDataType.Date;
dateCriteriaEnd.Value = maxDate.ToString();
searchCriteria.Add(dateCriteriaEnd);
PropertyCriteria dateCriteriaMin = new PropertyCriteria();
dateCriteriaMin.Condition = EPiServer.Filters.CompareCondition.GreaterThan;
dateCriteriaMin.Name = PAGE_DATE_PROPERTY;
dateCriteriaMin.Type = PropertyDataType.Date;
dateCriteriaMin.Value = minDate.ToString();
ltlMessage.Text += ", DateMin=" + minDate.ToString("dd/MMM/yyyy HH:mm:ss");
ltlMessage.Text += ", DateMax=" + maxDate.ToString("dd/MMM/yyyy HH:mm:ss");
searchCriteria.Add(dateCriteriaMin);
PageDataCollection pages = DataFactory.Instance.FindPagesWithCriteria(ListPageID(), searchCriteria);
// pgListing is a EPiServer:PageList control on the user control
pgListing.DataSource = pages;
pgListing.Paging = true;
pgListing.PagesPerPagingItem = 8;
pgListing.DataBind();