Also you may want to change custom codebehind class to standard one:
The final code for the page is the following:
So we added a button “btn” and handler “retrieveWebSites” for onclick event. In this handler we open context and load root web site (lines 36-39). In the onSuccess handler we load sub sites and in second onSuccess handler we enumerate all sites using get_count() method.
Hope it will help you with understanding of client object model.