When “must” I use asp.net CreateChildControls()?

前端 未结 4 1593
清酒与你
清酒与你 2020-12-19 16:49

While it seems that the \"right\" way to make a server control is to construct all child controls inside CreateChildControls call. But since it\'s difficult to know when it

4条回答
  •  时光取名叫无心
    2020-12-19 17:23

    You will get away with creating your controls in Init or Load until you write a control that needs to recreate the controls.

    I find it is always best to create the controls in CreateChildControls and then use EnsureChildControls to control ensure they are created when you need them. This allows you the ability to tear down the controls by setting ChildControlsCreated to false and have them recreated again when needed.

提交回复
热议问题