The INamingContainer interface tells
ASP.NET to do this. INamingContainer is a marker interface (i.e., an interface without any defined
methods) used by ASP.NET to identify the parent in a composite control to ensure unique names
or IDs for child controls as they are dynamically created during the page-rendering process.
Implementing the INamingContainer interface in the Pager server control activates this
mechanism, causing ASP.NET to prefix the ID of a control with the parent control??™s ID and a
colon. The previous left button in a Pager control named "pagerbtn" would therefore have an
ID value of "buttonLeft" but a UniqueID value of "pagerbtn$buttonLeft". Listing 5-16 contains
the full code listing for the Pager control.
230 CHAPTER 5 ?– SE RVER CONTROL EVENTS
Listing 5-16. The Pager Control Class File
using System;
using System.ComponentModel;
using System.Web.UI;
using System.Web.UI.WebControls;
using ControlsBook2Lib.Ch11.Design;
namespace ControlsBook2Lib.Ch05
{
[ToolboxData("<{0}:pager runat=server>{0}:pager>")]
public class Pager : CompositeControl
{
private static readonly object PageCommandKey = new object();
public event PageCommandEventHandler PageCommand
{
add
{
Events.AddHandler(PageCommandKey, value);
}
remove
{
Events.
Pages:
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334