As mentioned in the previous section, the properties exposed
are mainly those related to the styling of the child controls used. We will
have a thorough discussion on how those public properties are written. We will
take an example the RightListBoxStyle property whose code is shown below.
Listing 5
public Style RightListBoxStyle
{
get
{
if (this.IsTrackingViewState)
((IStateManager)this.rightListBoxStyle).TrackViewState();
this.ChildControlsCreated = false;
return this.rightListBoxStyle;
}
}
As you have noticed, we have just implemented the “get”
section of this property. There is no “set” section and, hence, the page
developer will not be able to do something as the following.
Listing 6
Style s1 = new Style();
bhMover.RightListBoxStyle = s1;
The page developer will not be able to set the property. So
how will he/she be able to configure this property? The answer is shown in the
code snippet below.
Listing 7
bhMover.RightListboxStyle.CssClass = “lstBox”;
You access the inner fields of the Style using the above
mentioned way and by doing so, you are first accessing the “get” section of the
property, once you have the get section, you are configuring items in it. What is
happening internally is that the local member leftLiatboxStyle is being
configured automatically. Here comes the question, how will be able to preserve
the configuration on the local member against postbacks, in a time there is no
way to use the ViewState in the “get” section of the property to preserve the
instance? This question will be answered later in this article when we will
override the SaveViewState, LoadvioewState and TrackViewState methods to be
able to preserve those instances.
As you have seen, we have explicitly checked to make sure
the control is tracking its ViewState given that the container control is doing
this properly.
The other properties are similar to this one explained above,
therefore, we will not go into the details of the other properties; you can
find them in the downloadable code that comes with this article.