TreeViews are good for displaying a hierarchical view of channels and postings. People instinctively know how to work through a TreeView—present one in front of your user and they know how to expand and collapse the folders to get its contents. We use the TreeView control that ships with MCMS to create a site map of the TropicalGreen site. In order to do that, we will write a recursive function (that is, a function that calls itself) to walk through the entire collection of channels and postings. A simple recursive function is shown below.
public void EatPizza() { InsertIntoMouth(Pizza); bool hungry = IsStomachGrowling(); while(hungry) { EatPizza(); } }
EatPizza()
continues to call itself as long as the IsStomachGrowling()
function returns a value of true. We will apply this technique to generate a site map of the Tropical Green site. Add a new Web User Control in the UserControls folder of the TropicalGreen project...