WebControl implemented as nested in UserControl or Page class

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

The code

public partial class _Default : System.Web.UI.Page
{
public class PHolder : PlaceHolder
{
}
protected void Page_Load(object sender, EventArgs e)
{
}
}

How can i add nested control PHolder into aspx or ascx.
I don't want to add control to controls collection in codebehind.

Is there any way to use some tag in ascx?

Thanks,
Alexey
 
public partial class _Default : System.Web.UI.Page
{
private PlaceHolder PHolder = new PlaceHolder();

Override OnInit(...)
{
PHolder.Controls.Add(new LiteralControl("some other Control"));
}

protected void Page_Load(object sender, EventArgs e)
{
}
}
 
I know this way, but:
"I don't want to add control to controls collection in codebehind.
Is there any way to use some tag in ascx?"
 
Back
Top