Prev | Current Page 776 | Next

Rob Cameron and Dale Michalk

"Pro ASP.NET 3.5 Server Controls and AJAX Components"

Since FindControl is not recursive, we look for the Result control on the
Page as well as at the same nesting level, which is the approach taken by the .Net Framework
data-bound control??™s DataSourceID property.
We also use this control reference to infer the correct value for the PageSize along with the
Query property value.
if (resControl == null)
resControl = (Result)this.NamingContainer.FindControl(ResultControl);
if (resControl == null)
throw new Exception("Either a Result control is not set on the " +
"Search Control or the Result control is not located on the " +
"Page or at the same nesting level as the Search control.");
SourceRequest[] sourceRequests = new SourceRequest[1];
sourceRequests[0] = new SourceRequest();
sourceRequests[0].Count = resControl.PageSize;
After getting the result data from the web service, we raise an event to any interested parties.
The type of this event is named LiveSearchSearched. This allows someone to use the Search
control as a data generator and build his or her own custom UI from the result sets. We follow
the design pattern for invoking this event through a protected method with On as the prefix to
the search name, OnLiveSearchSearched, as shown here:
OnLiveSearchSearched(new
LiveSearchSearchedEventArgs(searchResponse));
The LiveSearchSearchedEventArgs class wraps the results of a Live Search web service query.


Pages:
764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788