Creating a Default Template

The previous section discussed the ITemplate interface’s InstantiateIn() method. Normally, you don’t implement the InstantiateIn() method; you let ASP.NET Framework do it for you. However, if you want to supply a control with a default template, you need to implement this method.

The modified Article control in Listing 37.3 includes a default template for the ItemTemplate. The default template is used when an ItemTemplate is not supplied.

Listing 37.3. ArticleWithDefault.cs

images

images

The control in Listing 37.3 is similar to ...

Get ASP.NET 4 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.