To be able to set the URL that a user is taken to programmatically, you need to be able to access
the anchor tag that is defined in the control’s markup. To do this, you need to give it an id and a
runat="server" attribute. To be able to programmatically set the new NavigateUrl property that
you’ll add to the Banner control and to ensure that this property survives postbacks, you need to implement
a View State property. To show you why you need a View State property, the first three steps of
this exercise have you modify the About Us page so it sets the DisplayDirection of the Banner control
programmatically. You’ll then cause a postback so you can see that the value for the direction gets lost
c08.indd 302 08.indd 302 10/8/2012 9:57:04 AM 0/8/2012 9:57:04 AM
Adding Logic to Your User Controls x 303
because it doesn’t maintain its state in View State. The second part of the exercise then shows you how
to implement the NavigateUrl property that is able to maintain its state.