LoadViewState(state[0]);
if (state[1] != null)
((IStateManager)LabelStyle).LoadViewState(state[1]);
if (state[2] != null)
((IStateManager)TextboxStyle).LoadViewState(state[2]);
}
}
override protected object SaveViewState()
{
object baseState = base.SaveViewState();
object labelStyleState = (labelStyle != null) ?
((IStateManager)labelStyle).SaveViewState() : null;
object textboxStyleState = (textboxStyle != null) ?
((IStateManager)textboxStyle).SaveViewState() : null;
object[] state = new object[3];
state[0] = baseState;
state[1] = labelStyleState;
state[2] = textboxStyleState;
return state;
}
override protected void CreateChildControls()
{
ControlsBook2Lib.Ch04.Label label = new ControlsBook2Lib.Ch04.Label();
Controls.Add(label);
ControlsBook2Lib.Ch04.Textbox textbox = new ControlsBook2Lib.Ch04.Textbox();
Controls.Add(textbox);
}
158 CHAPTER 4 ?– T HE WEBCONTROL BASE CLASS AND CONTROL S TYLES
public override ControlCollection Controls
{
get
{
EnsureChildControls();
return base.Controls;
}
}
private void PrepareControlHierarchy()
{
ControlsBook2Lib.Ch04.Label label = (ControlsBook2Lib.Ch04.Label)Controls[0];
label.ApplyStyle(LabelStyle);
label.MergeStyle(ControlStyle);
ControlsBook2Lib.Ch04.
Pages:
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253