I had to make public controls accessible from another class. but it returns a zero reference error. I updated the initial entry
, EnsureChildControls . CreateChildControls , , , , , .
:.
public Button MyChildButton
{
get
{
EnsureChildControls();
return _myChildButton;
}
}
private Button _myChildButton;
...
protected override void CreateChildControls()
{
...
_myChildButton = new Button();
...
}
, , . :
public TextBox txtUrl;
:
public TextBox TxtUrl
{
get
{
EnsureChildControls();
return txtUrl;
}
}
private TextBox txtUrl;
CompositeControl, - Controls:
public override ControlCollection Controls
{
get
{
EnsureChildControls();
return base.Controls;
}
}
- CompositeControl, .
, , , , . . , , TextBox TxtUrl, Url, :
public string Url
{
get
{
EnsureChildControls();
return txtUrl.Text;
}
set
{
EnsureChildControls();
txtUrl.Text = value;
}
}