Help shape the future of CMS PaaS release notes! Take this quick survey and share your feedback.
Help shape the future of CMS PaaS release notes! Take this quick survey and share your feedback.
I never get the hang of this code formatting, let's see if I can get the code to post in human-readable format:
protected override void OnLoad(System.EventArgs e)
{
base.OnLoad(e);
Source.Selected += new DataSourceStatusEventHandler(Source_HandleErrors);
Source.Selected += new DataSourceStatusEventHandler(Source_HandleEmptyResult);
Source.Filter += new FilterEventHandler(Source_Filter);
Source.Filter += new FilterEventHandler(Source_Sort);
if (IsSearch)
{
SearchArea.Visible = true;
Form.DefaultButton = SearchButton.UniqueID;
}
else
{
SearchArea.Visible = false;
PropertyCriteriaControl tagCriterion = new PropertyCriteriaControl();
tagCriterion.Name = // Omitted lines to set up criteria...
Source.Criteria.Add(tagCriterion);
}
Search();
}
protected void Search_Click(object sender, EventArgs e)
{
Source.SearchQuery = SearchText.Text;
Source.OnlyWholeWords = this.SearchOnlyWholeWords.Checked;
Search();
}
protected void Search()
{
Result.Visible = true;
NoSearchResult.Visible = false;
Source.DataBind();
}
I looked at the code using Reflector and as far as I can see the Filter event is never raised if executing a property search. This is documented - in a way. My interpretation of the documentation was that if you perform a free text search, any proprety criteria are used to filter the result set (using automatically created handlers for the Filter event). However, any manually added filter should still be executed. This is not the case. Is there a good reason for this behaviour, is it a bug, or did I miss something?
I worked around the problem for now by not using the SearchDataSource for my property search but using FindPagesWithCriteria directly to get hold of the PageDataCollection and filter it.
Is the SearchDataSource.Filter event raised only under certain conditions? I have a page template that I use in two different "modes", either to execute a property search defined by page properties (by adding propertycriteria in codebehind) or if no such search is defined as an ordiary free text search. In free text mode the Filter event is raised just fine, but when property search is active it isn't raised. The Selected event is raised in both cases.
The code looks something like this: