Prev | Current Page 376 | Next

Rob Cameron and Dale Michalk

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


The other method that the MenuControlBuilder class overrides is AppendLiteralString. We
give this method an empty implementation to ignore the literal content that is between the
tags that hold the data.
public override void AppendLiteralString(string s)
{
// Ignores literals between tags
}
There are other features of ControlBuilder parsing that we left out in this demonstration.
For example, ControlBuilders can parse the raw string content between the server control??™s
parent tags and provide support for nested ControlBuilders to process child control content.
Please refer to the .NET Framework documentation for more information.
Going back to the BuilderMenu control, let??™s look at the implementation of IParserAccessor
and the AddParsedSubObject method. The following code simply adds the data object passed
into its internal ArrayList collection exposed by the menuData field. The only check it performs
is a type check to ensure the right type instance is being passed from the ControlBuilder associated
with the control.
protected override void AddParsedSubObject(Object obj)
{
if (obj is MenuItemData)
{
menuData.Add(obj);
}
}
Listings 6-7 and 6-8 show the final listing of BuilderMenu and its helper
MenuControlBuilder.


Pages:
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388