Prev | Current Page 800 | Next

Rob Cameron and Dale Michalk

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


// (main purpose is to detect paging events)
bool handled = false;
CommandEventArgs cea = args as CommandEventArgs;
// handle Page event by extracting new start index
// and calling HandleSearch method, which does the
// work of rebinding this control to the results
// from the web service
if (cea.CommandName == "Page")
{
StartIndex = Convert.ToInt32(cea.CommandArgument);
HandleSearch();
}
return handled;
}
The OnBubbleEvent implementation in Result grabs the index of the new page to display
with the Result control and then calls HandleSearch, which actually talks to Live Search.
HandleSearch is similar to the method of the same name in the Search control, except that it
doesn??™t have to look up a Result control; it simply sets the DataSource and calls DataBind on itself.
Styling the Result Control
After all of the child controls are created, either by CreateBlankControlHierarchy or
CreateControlHierarchy, the styles exposed by the Result control are applied. This is handled
in the RenderContents override discussed earlier. At the end of RenderContents, the code
invokes PrepareControlHierarchy to make this happen. It loops through all the ResultItem
controls and applies the appropriate Style object if the style was set on the Result control, as
shown here:
protected void PrepareControlHierarchy()
{
// apply all the appropriate style attributes
// to the items in the result output
foreach (ResultItem item in this.


Pages:
788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812